mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 07:20:59 +00:00
Added DogStatsD extended aggregation support.
Signed-off-by: Greg Chambers <gregc@unity3d.com>
This commit is contained in:
parent
58769c7b4d
commit
dcb9cc9446
2 changed files with 26 additions and 2 deletions
|
@ -229,8 +229,21 @@ func (p *Parser) LineToEvents(line string, sampleErrors prometheus.CounterVec, s
|
|||
return events
|
||||
}
|
||||
|
||||
// handle DogStatsD extended aggregation
|
||||
lineParts := strings.SplitN(elements[1], "|", 2)
|
||||
if strings.Contains(lineParts[0], ":") {
|
||||
aggValues := strings.Split(lineParts[0], ":")
|
||||
aggLines := make([]string, len(aggValues))
|
||||
tags := lineParts[1]
|
||||
|
||||
for i, aggValue := range aggValues {
|
||||
aggLines[i] = strings.Join([]string{aggValue, tags}, "|")
|
||||
}
|
||||
samples = aggLines
|
||||
} else {
|
||||
// disable multi-metrics
|
||||
samples = elements[1:]
|
||||
}
|
||||
} else {
|
||||
samples = strings.Split(elements[1], ":")
|
||||
}
|
||||
|
|
|
@ -403,6 +403,17 @@ func TestLineToEvents(t *testing.T) {
|
|||
"datadog tag extension with both valid and invalid utf8 tag values": {
|
||||
in: "foo:100|c|@0.1|#tag1:valid,tag2:\xc3\x28invalid",
|
||||
},
|
||||
"datadog timings with extended aggregation values": {
|
||||
in: "foo_timing:0.5:120:3000:10:20000:0.01|ms|#tag1:bar,#tag2:baz",
|
||||
out: event.Events{
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 0.0005, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 0.120, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 3, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 0.01, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 20, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
&event.ObserverEvent{OMetricName: "foo_timing", OValue: 0.00001, OLabels: map[string]string{"tag1": "bar", "tag2": "baz"}},
|
||||
},
|
||||
},
|
||||
"timings with sampling factor": {
|
||||
in: "foo.timing:0.5|ms|@0.1",
|
||||
out: event.Events{
|
||||
|
|
Loading…
Reference in a new issue