grok_exporter icon indicating copy to clipboard operation
grok_exporter copied to clipboard

JSON Webhook Parsing

Open BuffaloWill opened this issue 5 years ago • 3 comments
trafficstars

Thank you for the great tool. I think I've run into a bug with JSON parsing.

I have a JSON object like this being sent to /webhook:

{
    "transaction": {
        "messages": [
            {
                "details": {
                    "info": "this is what I want"
                    }
            }
        ]
    }

I've tried the following configuration but it throws an error the selector path cannot be found:

...
webhook_format: json_single
webhook_json_selector: .transaction.messages[0].details.info
...

I've also tried switching to webhook_format:json_bulk but I can't find a working webhook_json_selector. Any help would be greatly appreciated on how to move forward.

BuffaloWill avatar Apr 13 '20 15:04 BuffaloWill

Thanks for reporting. I'll try to look into it over the weekend...

fstab avatar Apr 16 '20 20:04 fstab

The webhook_json_selector currently does not support array indexes like [0], but it looks like this should be easy to implement if you don't need full jsonpath support. I'll get a simple implementation done that will cover your example above.

fstab avatar Apr 25 '20 21:04 fstab

I pushed a fix, supporting simple array indexes in webhook_json_selector like in your example above. If you build grok_exporter from source from the master branch it should work now. Thanks for reporting this!

fstab avatar Apr 26 '20 22:04 fstab