Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: JSON selector not found leads to excessive logging and incorrect metric generation #158

Open
thomas315 opened this issue Jun 25, 2021 · 0 comments

Comments

@thomas315
Copy link

When webhook_format: json_bulk or json_lines is used there are cases in which matches and metric creation are not working correctly.
Additionally the whole request body is getting logged in

level=warning msg="Unable to find selector path" post_body="<request body>" webhook_json_selector=.requesterDN

Grok exporter version:
v1.0.0.RC5

configuration file:

global:
  config_version: 3
input:
  type: webhook
  webhook_path: /webhook
  webhook_format: json_lines
  webhook_json_selector: .requesterDN

server:
  port: 9144

metrics:
  - type: counter
    name: metric_name_count
    help: something
    match: 'john'

Case 1:

What did you do?

curl -X POST -H "Content-Type: application/json" -d '{ "logtype":"access", "requesterDN":"john" }
{ "logtype":"access", "requesterDN":"mark" }' http://localhost:9146/webhook

or

curl -X POST -H "Content-Type: application/json" -d '{ "logtype":"access", "requesterDN":"mark" }
{ "logtype":"access", "requesterDN":"john" }' http://localhost:9146/webhook

What did you expect to see?
grok_exporter_lines_total{status="ignored"} = 1
grok_exporter_lines_total{status="matched"} = 1

What did you see instead? Under which circumstances?
this works as expected!

Case 2:

What did you do?

curl -X POST -H "Content-Type: application/json" -d '{ "logtype":"access" }
{ "logtype":"access", "requesterDN":"john" }' http://localhost:9146/webhook

What did you expect to see?
grok_exporter_lines_total{status="ignored"} = 0 # discussable if it this metric should be increased if there is no JSON selector found
grok_exporter_lines_total{status="matched"} = 1

What did you see instead? Under which circumstances?
grok_exporter_lines_total{status="ignored"} = 0
grok_exporter_lines_total{status="matched"} = 0

Log:

level=warning msg="Unable to find selector path" post_body="{ \"logtype\":\"access\" }\n{ \"logtype\":\"access\", \"requesterDN\":\"john\" }" webhook_json_selector=.requesterDN

Case 3:

What did you do?

curl -X POST -H "Content-Type: application/json" -d '{ "logtype":"access", "requesterDN":"john" }
{ "logtype":"access" } ' http://localhost:9146/webhook

What did you expect to see?
grok_exporter_lines_total{status="ignored"} = 0
grok_exporter_lines_total{status="matched"} = 1

What did you see instead? Under which circumstances?
grok_exporter_lines_total{status="ignored"} = 0 # discussable if it this metric should be increased if there is no JSON selector found
grok_exporter_lines_total{status="matched"} = 1
Metrics are correctly increased in this case.

Logs:

level=warning msg="Unable to find selector path" post_body="{ \"logtype\":\"access\", \"requesterDN\":\"john\" }\n{ \"logtype\":\"access\" } " webhook_json_selector=.requesterDN

Same log as for Case 2 but correct increased metrics.

@thomas315 thomas315 changed the title JSON selector not found leads to excessive logging and incorrect metric generation Bug: JSON selector not found leads to excessive logging and incorrect metric generation Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant