-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Support JSON Path-like json parsing #1363
Comments
this should also support parsing timestamps in the same way |
@sparrc response to your question in #1554 : A: This is great for use cases where there's not a telegraf instance loading the data to a kafka topic for ingestion, hence it's not trivial to load the data with the influx line protocol. For my specific use case we are getting a stream of syslog lines from and external server. The syslog line is grokked into JSON and loaded into a Kafka topic. Then we have Telegraf read that kafka topic to load the metrics into a metric storage backend (influx, graphite, etc). |
Hello, I opened #2066 and am taking a look at the more generic solution proposed here. What are you thinking in terms of configuration @sparrc ? Currently, I see that httpjson conf can..
What should a user of the generic JSON parser be able to configure in addition to the above? Should the new JSONParser be backwards compatible with the existing parser? |
@kevinjos this issue is specific to JSON parsing, not the httpjson plugin. For that reason, there will not be a change to the first bullet-point. Ideally it will be backwards-compatible, tag_keys will continue to be supported, and if the JSON parsing rules fail then it will fall back to the current behavior, which is to parse the top-level arrays. I haven't thought too much about what this will look like as I haven't had time to work on it, but the idea would be to create a generic way for users to specify paths to nested objects and arrays, and have custom patterns for parsing different json object types. |
I opened a PR that introduces jsonq to the json parser to support parsing nested objects and arrays of objects into unique metrics with default, top-level and object-specific tags: Feedback is much appreciated. |
I'd like to add one more use-case here: Mqtt-consumer with Json payload, where Timestamp overwrite would be very useful. |
@olsky what do you mean by "timestamp overwrite"? |
by "timestamp overwrite" I mean: use a custom timestamp (also in the past), not the instance when the message is received. |
Hi all, |
Anyone have opinions on JSONPath vs jsonq vs json-ptr? I think the parser could work something like what we sketched up for a XML parser on #1758. |
any news ? |
I merged a bunch of new features into the existing JSON parser, I think it may meet the needs for many watching this issue. Check the JSON data format for details. There is still a place for a new parser, so I will keep this issue open. |
It's a shame there is still no way to parse something like this:
|
From a nested json structure, if I want to parse only specific numeric fields, this solution of "field_keys" would have helped a lot. The current implementation only works if all the fields I want are in one specific chunk of the json (by leveraging json_query). Would be great to have a support a list of json_query filters OR have a way to specify which fields should be measured. |
You may be able to do with GJSON's multipaths syntax. If you show an example document I'd have a better idea if this will work for you. |
@danielnelson : tried using the multipath syntax but cannot get it to work.
Say I have a nested JSON like described above with many more numerical fields, and I am only interested in the following: "fields.duration", "fields.status", "fields.json#duration". |
When you say many more numerical fields, do you mean the like:
Or is it more like this?
|
Like:
For what I need, we can assume "fields.json" is an array of one item. I only care about some properties of "fields" and some properties of "fields.json", I don't need anything from the nested structure "fields.json.nest". |
How about something like this? It's a pretty basic multiselect but we need to provide a custom name for duration to avoid the naming conflict.
|
Sample Data:
Telegraf Config:
I get the following error:
|
Can you open a new bug issue for this and we can address it in 1.14.5. Probably related to the |
Thanks, will do. It does not work even if I remove the |
filed #7699 |
+1 to the issue. It will be great to have an option parse tags like this:
|
The new JSON_v2 parser ( |
Feature Request
Proposal:
Support something similar to JSONPath for customizing which fields/paths of json get picked up as tags/fields/types/etc.
Doesn't need to be JSONPath specifically, since TBH the official json path spec is fairly ugly. Something more simple like https://github.com/jmoiron/jsonq would work as well.
Current behavior:
flattens json into numerical fields only, grabs tags only from the top level.
Desired behavior:
more customization to deal better with diverse range of different json formats.
Use case: [Why is this important (helps with prioritizing requests)]
Telegraf frequently gets issues opened for users who want specific changes & modifications to the json parser for their particular use-case. These cannot all be satisfied without a truly generic solution.
The text was updated successfully, but these errors were encountered: