{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/737","repository_url":"https://api.github.com/repos/influxdata/telegraf","labels_url":"https://api.github.com/repos/influxdata/telegraf/issues/737/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/telegraf/issues/737/comments","events_url":"https://api.github.com/repos/influxdata/telegraf/issues/737/events","html_url":"https://github.com/influxdata/telegraf/pull/737","id":135503607,"number":737,"title":"StatsD plugin: Support multiple fields for timers","user":{"login":"mattheath","id":181548,"avatar_url":"https://avatars.githubusercontent.com/u/181548?v=3","gravatar_id":"","url":"https://api.github.com/users/mattheath","html_url":"https://github.com/mattheath","followers_url":"https://api.github.com/users/mattheath/followers","following_url":"https://api.github.com/users/mattheath/following{/other_user}","gists_url":"https://api.github.com/users/mattheath/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheath/subscriptions","organizations_url":"https://api.github.com/users/mattheath/orgs","repos_url":"https://api.github.com/users/mattheath/repos","events_url":"https://api.github.com/users/mattheath/events{/privacy}","received_events_url":"https://api.github.com/users/mattheath/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-22T18:38:15Z","updated_at":"2016-02-22T21:01:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/influxdata/telegraf/pulls/737","html_url":"https://github.com/influxdata/telegraf/pull/737","diff_url":"https://github.com/influxdata/telegraf/pull/737.diff","patch_url":"https://github.com/influxdata/telegraf/pull/737.patch"},"body":"Currently the [statsd plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/statsd) supports multiple fields per measurement for _counters_, but not _timers_ as the statsd plugin uses fields in InfluxDB to record the various stats (upper, mean, percentiles etc). The current behaviour is to append the field name (if parsed via a template) to the measurement name, which in our use case clutters the measurement namespace.\r\n\r\nThis PR changes the behaviour with an optional config setting of `multiple_timer_fields` (disabled by default) to allow multiple fields per measurement to be recorded on timers by prepending the stat name with the field name.\r\n\r\nAs an example, in the case of _counters_ we can record success and error counters as fields within the same measurement. So a measurement of `api_request` and a template such as `measurement.field` allows us to increment counters by sending statsd values such as `api_request.success:1|c` and `api_request.error:1|c` which results in a measurement in influxDB of:\r\n\r\n```\r\nselect * from api_request;\r\n\r\n|         time         | success | error |    host     | metric_type | other_fields...\r\n|----------------------|---------|-------|-------------|-------------|-----------------\r\n| 2016-02-22T15:31:20Z |      10 |     1 | example.com | counter     |\r\n```\r\n\r\nIn contrast, timings currently create two measurements, with the various calculated stats:\r\n\r\n```\r\nselect * from api_request_success;\r\n\r\n|         time         | count | lower | upper | mean | 90_percentile | stddev |\r\n|----------------------|-------|-------|-------|------|---------------|--------|\r\n| 2016-02-22T15:31:20Z |     5 |     1 |    11 |    3 |            11 |      4 |\r\n\r\nselect * from api_request_error;\r\n\r\n|         time         | count | lower | upper | mean | 90_percentile | stddev |\r\n|----------------------|-------|-------|-------|------|---------------|--------|\r\n| 2016-02-22T15:31:20Z |     5 |     2 |    22 |    6 |            22 |      8 |\r\n```\r\n\r\nIn this case the number of fields is comparatively small, and we'd like to combine both of these into the same measurement, both tidying up our measurement namespace, and [reducing the series cardinality](https://docs.influxdata.com/influxdb/v0.10/concepts/glossary/#series-cardinality) in InfluxDB. This results in a single measurement as below:\r\n\r\n```\r\nselect * from api_request;\r\n\r\n|         time         | error_count | error_lower | error_upper | error_mean | error_90_percentile | error_stddev | success_count | success_lower | success_upper | success_mean | success_90_percentile | success_stddev |\r\n|----------------------|-------------|-------------|-------------|------------|---------------------|--------------|---------------|---------------|---------------|--------------|-----------------------|----------------|\r\n| 2016-02-22T15:31:20Z |           5 |           2 |          22 |          6 |                  22 |            8 |             5 |             1 |            11 |            3 |                    11 |              4 |\r\n```\r\n\r\nWould really love feedback and suggestions for improvements!\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/comments/187380472","html_url":"https://github.com/influxdata/telegraf/pull/737#issuecomment-187380472","issue_url":"https://api.github.com/repos/influxdata/telegraf/issues/737","id":187380472,"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-02-22T21:01:42Z","updated_at":"2016-02-22T21:01:42Z","body":"But there's a simple workaround, isn't there? Just remove `field` from your timing template (since you weren't using it anyways)\r\n\r\nSince we are not at a 1.0 release version yet, it's generally been treated as OK to break backwards compatability (as long as we call it out in the changelog)"}}