-
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
fix(parsers.avro): Do not force addition of timestamp as a field #13856
Conversation
Ah, I see the problem. The field selection is done before the parsing-as-timestamp, so if you tell the plugin you want as a timestamp, and then it's not one of your fields: So all I need to do there is take the timestamp from the raw input data, and not from the stuff already parsed into fields. |
There's another case here, and I think what I am doing is the right thing but I do not know. What I have is working fine for flattening or not flattening maps. But even if you are not flattening the map (which is to say, you don't get measurements with the data type stitched to the field), I'm still flattening arrays, to {field_name}{field_sep}{index}, because I don't see a better way to do array values that will work with InfluxDB line protocol. Example: you have (The only other remotely plausible way seems like it would be outputting a string which is the JSON representation of the array, but that requires knowledge of how to interpret that string on the receiving end.) And while it's true that people may not be outputting to InfluxDB, the telegraf testutils definitely expect to be able to parse metrics from a file that's in line protocol, so I think it's safe to consider that our default format. |
@athornton before giving this a review I'm trying to understand why the behavior was what it was... Please bear with me as I'm not an Avro expert. Some questions:
|
I'm not an Avro expert either, but I can ask @afausti about, at least, how we're doing it here.
And actually I have a question about #1: The test utils all assume that you're basically parsing to line protocol. Is that a good generic assumption about telegraf? Obviously there are at least some people who do not output to InfluxDB at all, but in my mind, the point of telegraf is primarily to feed InfluxDB and other output cases are secondary--that is, I should think of it as a very flexible converter for InfluxDB measurements, and not as a generic converter like some kind of imagemagick equivalent for metric events. But I don't know if I'm actually correct about that. |
c479139
to
48cb0e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@athornton can you please rebase this after PR #13855 is merged!? Furthermore, I do have one question regarding the supplied_timestamp_fields_unspecified
test case...
plugins/parsers/avro/testdata/supplied_timestamp_fields_unspecified/telegraf.conf
Show resolved
Hide resolved
4879d28
to
26a2140
Compare
26a2140
to
a790583
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @athornton!
Required for all PRs
resolves #13821
Dropped the forced addition of the timestamp as a field, and touched up the JSON test case to note that I did want the timestamp as a field.
Note that this also includes the fix for Issue #13854 / PR #13855, because it impacts correct timestamp specification. We might want to just merge this PR instead and drop that one, although it's just going to be "skipping already-applied-commit" if we don't.