diff --git a/pkg/line/line.go b/pkg/line/line.go index 98c70e3..e591b30 100644 --- a/pkg/line/line.go +++ b/pkg/line/line.go @@ -229,8 +229,21 @@ func (p *Parser) LineToEvents(line string, sampleErrors prometheus.CounterVec, s return events } - // disable multi-metrics - samples = elements[1:] + // 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], ":") } diff --git a/pkg/line/line_test.go b/pkg/line/line_test.go index bd57c9b..c084b22 100644 --- a/pkg/line/line_test.go +++ b/pkg/line/line_test.go @@ -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{