-
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 output data format, support nanosecond timestamps. #2124
Comments
The agent precision refers more to the precision at the metric collection point. InfluxDB is specifically a data protocol which supports nanosecond precision. So this is just a request for the JSON output format to support nanosecond timestamps. |
If you'd rather call this a feature request than a bug fix I'm open to that; I'm just having difficulty with the fact that the timestamp in the It just seemed to me that the timestamp should be consistent, regardless of the data_format that is defined (so either both should always return seconds or the timestamp returned for both should be the timestamp that was generated when the metric was collected, not a truncated timestamp for one and a full-fidelity timestamp for the other. |
I disagree, I think that the output format defines the precision. Influx is defined to be |
OK, I see that now. If I change the precision to Is that documented somewhere (that the time returned for the Given that behavior, then I agree that this is a feature request. That said, I don't know how the change would be supported since it would be a breaking change for people who are currently collecting |
Yes it would need to be an argument for the json output format, graphite doesn't support anything other than |
That actually makes things much simpler than I thought it would be; let me see if I can throw together a pull request and submit something in short order on this. I was afraid I'd have to pull the precision from the Agent configuration somehow; having it as a configuration parameter in the Look for a CLA signature from me and a pull request sometime this week :) |
Bug report
In the current released version of telegraf and the latest version on the master branch, the precision value declared for metrics generated by the agent is not honored for all Serializers. Specifically, when we select a
file
output filter and request aninflux
data_format, with the precision value for the agent set to1ns
(for nanosecond precision), we see values that look like this in the output:On the other hand, when we change that output data_format value to
json
, the values that we see look like this:It's obvious that the timestamp values shown in the
influx
data_format example shown above are actual nanosecond timestamp values, while the timestamps shown for thejson
data_format example have been truncated to the nearest second.It's also obvious where this occurs. While the precision for the agent does set the precision of the time stamp for the metrics that are collected, when converting that data to JSON in this line of code, that timestamp is converted to a time in seconds. The
influx
data_format is actually generated in a completely different fashion than thejson
data_format; by calling a simplem.Serialize()
method in the current commit on the master branch of the repository or[]string{metric.String()}
method in the v1.1.1 release of telegraf.Relevant telegraf.conf:
This is the telegraf.conf file that was used for the
influx
data_format example:while this is the telegraf.conf file used for the
json
data_format example:both were generated by using the
telegraf -input-filter system -output-filter file config
command and hand editing the resulting configuration file to set the precision to1ns
so that we would get timestamps to the nearest nanosecond in the metrics that were measured by the agent; the only difference is the data_format for thefile
output filter.System info:
Tested using Telegraf version 1.1.1 and a version of Telegraf built from the latest commit to the master branch (504f4e6 ) under both CentOS 7.2 and OS X 10.12.7
Steps to reproduce:
file
output filter using thetelegraf -input-filter system -output-filter file config
command1ns
json
in the copy that you just createdtelegraf --config <filename>
where the string<filename>
is the configuration that you want to test (the first file and the second file)Expected behavior:
I expected to see that the timestamps for both the
influx
andjson
data_format cases would have the same precision; the precision declared in the configuration of the telegraf agent.Actual behavior:
The precision of the metric timestamps depends not only on the precision declared in the configuration of the telegraf agent but also on the data_format declared for the output filter, specifically:
influx
data_format case, the nanosecond precision that was declared for the agent was honored, and the timestamps shown in the output generated by the agent were to the nearest nanosecondjson
data_format case the precision declared for the agent was not honored, instead the timestamps associated with the metric (which were to the nearest nanosecond) were arbitrarily converted to timestamp values in seconds (by dividing the timestamp associated with each metric value, converted to nanoseconds, by 1000000000).The text was updated successfully, but these errors were encountered: