-
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
Adds a 'timestamp_units' configuration parameter #2143
Conversation
What about calling it 'precision' as this is what it's called everywhere else? |
I had called the parameter that I'm adding to the configuration file the After seeing @sparrc's comments on that pull request I think I would have to agree that the So, with that in mind, does the name I've chosen for this parameter work for for you, @phemmer? |
sorry this PR fell through the cracks, but your change needs to be for the JSON output serializer ONLY. Do not make any changes to the telegraf agent. You should only need to make changes to the json serializer. Also please make an attempt to reduce the verbosity of your documentation/comments. This is a simple config option that changes the precision of the timestamp output, you don't need to say much more than that. |
I guess I'm a little confused, @sparrc; I thought I'd made a minimal set of changes based on your comments on my last pull request, but evidently not. The issue (as I see it) is that currently the JSON serializer outputs things in seconds, and we would really like the option to have JSON data tagged with timestamps in another unit (we want nanoseconds, but it should support the same units that are supported elsewhere in Telegraf...milliseconds, microseconds, etc.). Unfortunately, as you pointed out in your comments on my previous pull request related to this issue, the current behavior for any JSON data that is output is to output the data with a timestamp in seconds. As such, I thought I would need to make a change to how the agent is configured so that the user could (if they would like) choose a different units value for the timestamps included when the metrics collected were output in JSON but if that value was not specified in the configuration the current behavior (outputting the timestamps in seconds) would be maintained. So that's why I made what I felt were a minimal set of changes outside of the JSON serializer itself; to preserve the current behavior but allow for finer precision in the timestamps if we wanted it. As I was testing my changes, however, I ran across another, related issue. If you enter the timestamp units as If you want me to reduce this to a one-line change that always outputs the JSON data with nanoseconds units for the time string that's a much simpler thing to do, but I think there will have to be changes made outside of the serializer to deal with the two issues I've outlined above. I'm happy to rebase the code on this branch to make changes to it if you want me to, but I'm not sure that I can limit the changes to only the serializer (unless I'm missing something obvious; if so, enlighten me). |
Resolves #2124
The changes in this pull request add a new
timestamp_units
parameter to the agent configuration. This parameter only effects the timestamps output for thejson
data_format, and take the effect of a duration string (values like1ns
,1us
,1ms
and1s
are all supported). If this parameter is not defined in the configuration file then the current behavior is preserved (the timestamps output as part of thejson
data_format are truncated to the nearest second).The following output shows the effect of this parameter when it is unset (the current default) and when it is set to
1us
and1ns
(so that the timestamps are output in microseconds and nanoseconds, respectively) for a configuration that is collectingsystem
data to the defaultfile
output:Required for all PRs: