StatsD plugin: Support multiple fields for timers #737
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the statsd plugin 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.
This 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.As 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 asmeasurement.field
allows us to increment counters by sending statsd values such asapi_request.success:1|c
andapi_request.error:1|c
which results in a measurement in influxDB of:In contrast, timings currently create two measurements, with the various calculated stats:
In 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 in InfluxDB. This results in a single measurement as below:
Would really love feedback and suggestions for improvements!