-
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
json_query not parsing through all entries in the JSON array #6138
Comments
This is a bug in the tail plugin caused by some special logic for the csv parser when reading the first line of the file. We'll put together a fix for the next release. |
Appreciate your looking into it. Thanks Daniel! |
@danielnelson been playing about with tests on this one and come to realise that there is a little interface design discrepancy going on between the tail plugin, the parser interface and the json implementation. The parser interface assumers 1 metric per line: telegraf/plugins/parsers/registry.go Lines 38 to 58 in 877c423
Parse can take multiple lines and return multiple metrics. Which could potentially be used to circumvent this design constraint. However, as it stands, the tail parsers attempts to parse multiple lines using telegraf/plugins/inputs/tail/tail.go Lines 200 to 213 in 877c423
This leads me to think that in the long run perhaps the interface needs to be redesigned in order to acknowledge that a single newline delimited line can produce > 1 metrics. |
Yes, I'm hoping to remove the ParseLine function from this interface. Since we want to support arbitrary binary formats we shouldn't have a line based method; the containing plugin should handle transport level framing and the parser should understand inter-metric level framing. First though we need a solution for parser state. The tail plugin is using the ParseLine function to check headers only once per file, and it would be easy to remove this, but we also need to consider when the parser is used by other plugins such as the file plugin. In the |
I get you. The tail plugin processes line by line. The file plugin processes entire document contents in one. However, both depend upon parser interface. The parser needs to be able to handle being called either line by line or entire documents and be able to support the effect of a parser changing state when called in a line by line fashion (i.e. csv first line means header is parsed and then that effects all the following metrics). Currently, the Once we have this we can move the acknowledgement of a header being parsed into the state of the csv parser. Meaning the first call to Parse behaves diferently to the subsequent calls. Correct me if I am misunderstanding anything. |
Hi, I think there is a bug in how JSON array entries are being parsed by JSONQuery. Would really appreciate guidance on whether I've made a configuration error or this is indeed reproducible by other folks.
Relevant telegraf.conf:
System info:
Telegraf v 1.11.2
OS: Debian 9
Steps to reproduce:
https://github.com/influxdata/telegraf/tree/master/plugins/parsers/json#query
So a sample entry in the file would be -
Expected behavior:
All entries in the array are parsed (very similar to the posted example)
Actual behavior:
Only the first array entry is being parsed.
{"fields":{"age":44},"name":"test-key","tags":{"first":"Dale","host":"test-us1-instance","path":"/test.log"},"timestamp":1563466236}
The text was updated successfully, but these errors were encountered: