{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/2139","repository_url":"https://api.github.com/repos/influxdata/telegraf","labels_url":"https://api.github.com/repos/influxdata/telegraf/issues/2139/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/telegraf/issues/2139/comments","events_url":"https://api.github.com/repos/influxdata/telegraf/issues/2139/events","html_url":"https://github.com/influxdata/telegraf/pull/2139","id":194238872,"number":2139,"title":"Adds an 'output_precision' configuration parameter","user":{"login":"tjmcs","id":1375734,"avatar_url":"https://avatars.githubusercontent.com/u/1375734?v=3","gravatar_id":"","url":"https://api.github.com/users/tjmcs","html_url":"https://github.com/tjmcs","followers_url":"https://api.github.com/users/tjmcs/followers","following_url":"https://api.github.com/users/tjmcs/following{/other_user}","gists_url":"https://api.github.com/users/tjmcs/gists{/gist_id}","starred_url":"https://api.github.com/users/tjmcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjmcs/subscriptions","organizations_url":"https://api.github.com/users/tjmcs/orgs","repos_url":"https://api.github.com/users/tjmcs/repos","events_url":"https://api.github.com/users/tjmcs/events{/privacy}","received_events_url":"https://api.github.com/users/tjmcs/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-08T03:34:38Z","updated_at":"2016-12-08T08:58:19Z","closed_at":"2016-12-08T08:58:18Z","pull_request":{"url":"https://api.github.com/repos/influxdata/telegraf/pulls/2139","html_url":"https://github.com/influxdata/telegraf/pull/2139","diff_url":"https://github.com/influxdata/telegraf/pull/2139.diff","patch_url":"https://github.com/influxdata/telegraf/pull/2139.patch"},"body":"Resolves #2124 \r\n\r\nThe changes in this pull request add a new `output_precision` configuration parameter to the output plugins that utilize the `Serializer` interface to send `influx`, `graphite`, or `json` formatted data to various outputs (`amqp`, `file`, `kafka`, `mqtt`, `nats`, and `nsq`).\r\n\r\nThe format used to specify this precision value is the same format that is used to specify the precision of the timestamps used with the metrics collected by the agent (values like `\"1ns\"`, `\"1us\"`, `\"1ms\"` and `\"1s\"` are all supported), and the documentation in the comments for\r\nthe current Agent `precision` configuration parameter was changed a bit to reflect the real\r\nvalue that should be set if you want to measure timestamps in times other than seconds\r\n(choosing a value of `\"ns\"` for this parameter results in a precision of `0ns`, which is then\r\ntreated like a precision of `1s` by the code since `1s` is the default in the case where a\r\nprecision value was not specified).\r\n\r\nThe changes that are made in this pull request will only effect the output of data in a `json`\r\ndata_format (the timestamps for the `graphite` and `influx` data_formats remain as they were after this pull request is merged, with the timestamps returned in the `graphite` data_format having a fixed precision of `1s` and timestamps for the the `influx` data_format having a fixed precision of `1ns`, as they always have), and the outputs that use the `Serialize` method to output data in a `json` data_format are the only outputs that have been changed.  As was stated earlier, using this new code with an existing `telegraf.conf` file (where this new configuration parameter is not specified for any of those outputs) will result in the same behavior that is seen currently (where all data in a `json` data_format is output with timestamps that have been truncated to the nearest second, regardless of the precision with which they were measured).\r\n\r\nThe following output shows the result of these changes when an `output_precision` value is not specified in the configuration file for a `file` output with a `json` data_format (the equivalent to the current released behavior of the telegraf agent), in which case a default value of one second is used:\r\n```bash\r\n$ telegraf --config telegraf-sys-file.conf\r\n2016-12-08T03:11:59Z I! Starting Telegraf (version dev-42-g7a1a91d)\r\n2016-12-08T03:11:59Z I! Loaded outputs: file\r\n2016-12-08T03:11:59Z I! Loaded inputs: inputs.system\r\n2016-12-08T03:11:59Z I! Tags enabled: host=Toms-MacBook-Pro.local\r\n2016-12-08T03:11:59Z I! Agent Config: Interval:10s, Quiet:false, Hostname:\"Toms-MacBook-Pro.local\", Flush Interval:10s\r\n{\"fields\":{\"load1\":1.74,\"load15\":1.55,\"load5\":1.61,\"n_cpus\":8,\"n_users\":9},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166720}\r\n{\"fields\":{\"uptime\":2662650,\"uptime_format\":\"30 days, 19:37\"},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166720}\r\n{\"fields\":{\"load1\":1.63,\"load15\":1.54,\"load5\":1.59,\"n_cpus\":8,\"n_users\":9},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166730}\r\n{\"fields\":{\"uptime\":2662660,\"uptime_format\":\"30 days, 19:37\"},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166730}\r\n^C2016-12-08T03:12:48Z I! Hang on, flushing any cached metrics before shutdown\r\n\r\n$ \r\n```\r\nAnd this output shows the result when an `output_precision` value is specified, with the value chosen set to `1ns` (so that the timestamps are output in nanosecond precision):\r\n```bash\r\n$ telegraf --config telegraf-sys-file-1ns.conf\r\n2016-12-08T03:12:24Z I! Starting Telegraf (version dev-42-g7a1a91d)\r\n2016-12-08T03:12:24Z I! Loaded outputs: file\r\n2016-12-08T03:12:24Z I! Loaded inputs: inputs.system\r\n2016-12-08T03:12:24Z I! Tags enabled: host=Toms-MacBook-Pro.local\r\n2016-12-08T03:12:24Z I! Agent Config: Interval:10s, Quiet:false, Hostname:\"Toms-MacBook-Pro.local\", Flush Interval:10s\r\n{\"fields\":{\"load1\":1.86,\"load15\":1.56,\"load5\":1.64,\"n_cpus\":8,\"n_users\":9},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166750050507703}\r\n{\"fields\":{\"uptime\":2662680,\"uptime_format\":\"30 days, 19:38\"},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166750050587563}\r\n{\"fields\":{\"load1\":1.8,\"load15\":1.56,\"load5\":1.64,\"n_cpus\":8,\"n_users\":9},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166760052514430}\r\n{\"fields\":{\"uptime\":2662690,\"uptime_format\":\"30 days, 19:38\"},\"name\":\"system\",\"tags\":{\"host\":\"Toms-MacBook-Pro.local\"},\"timestamp\":1481166760052566832}\r\n^C2016-12-08T03:12:48Z I! Hang on, flushing any cached metrics before shutdown\r\n\r\n$ \r\n```\r\n\r\n### Required for all PRs:\r\n\r\n- [ ] CHANGELOG.md updated (we recommend not updating this until the PR has been approved by a maintainer)\r\n- [X] Sign [CLA](https://influxdata.com/community/cla/) (if not already signed)\r\n- [ ] README.md updated (if adding a new plugin)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/comments/265687795","html_url":"https://github.com/influxdata/telegraf/pull/2139#issuecomment-265687795","issue_url":"https://api.github.com/repos/influxdata/telegraf/issues/2139","id":265687795,"user":{"login":"sparrc","id":7155926,"avatar_url":"https://avatars.githubusercontent.com/u/7155926?v=3","gravatar_id":"","url":"https://api.github.com/users/sparrc","html_url":"https://github.com/sparrc","followers_url":"https://api.github.com/users/sparrc/followers","following_url":"https://api.github.com/users/sparrc/following{/other_user}","gists_url":"https://api.github.com/users/sparrc/gists{/gist_id}","starred_url":"https://api.github.com/users/sparrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparrc/subscriptions","organizations_url":"https://api.github.com/users/sparrc/orgs","repos_url":"https://api.github.com/users/sparrc/repos","events_url":"https://api.github.com/users/sparrc/events{/privacy}","received_events_url":"https://api.github.com/users/sparrc/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T08:58:18Z","updated_at":"2016-12-08T08:58:18Z","body":"Thank you for the PR but there are few things wrong with this:\r\n\r\n1. I don't agree with changing `ns`->`1ns`, `ms`->`1ms`, etc., which would also be a breaking change\r\n2. This change needs to happen at a much lower level. This needs to happen in the same way the the `graphite` serializer gets configured, which is in config.go, see https://github.com/influxdata/telegraf/blob/master/internal/config/config.go#L1240-L1278"}}
{"actor":{"display_login":"sparrc"}}