diff --git a/plugins/outputs/datadog/README.md b/plugins/outputs/datadog/README.md index c9e4a8a81faea..6b99e97fa34bf 100644 --- a/plugins/outputs/datadog/README.md +++ b/plugins/outputs/datadog/README.md @@ -33,5 +33,11 @@ field key with a `.` character. Field values are converted to floating point numbers. Strings and floats that cannot be sent over JSON, namely NaN and Inf, are ignored. +We do not send `Rate` types. Counts are sent as `count`, with an +interval hard-coded to 1. Note that this behavior does *not* play +super-well if running simultaneously with current Datadog agents; they +will attempt to change to `Rate` with `interval=10`. We prefer this +method, however, as it reflects the raw data more accurately. + [metrics]: https://docs.datadoghq.com/api/v1/metrics/#submit-metrics [apikey]: https://app.datadoghq.com/account/settings#api diff --git a/plugins/outputs/datadog/datadog.go b/plugins/outputs/datadog/datadog.go index c97929eaefd05..682be05070b66 100644 --- a/plugins/outputs/datadog/datadog.go +++ b/plugins/outputs/datadog/datadog.go @@ -33,10 +33,12 @@ type TimeSeries struct { } type Metric struct { - Metric string `json:"metric"` - Points [1]Point `json:"points"` - Host string `json:"host"` - Tags []string `json:"tags,omitempty"` + Metric string `json:"metric"` + Points [1]Point `json:"points"` + Host string `json:"host"` + Type string `json:"type,omitempty"` + Tags []string `json:"tags,omitempty"` + Interval int64 `json:"interval"` } type Point [2]float64 @@ -85,10 +87,21 @@ func (d *Datadog) Write(metrics []telegraf.Metric) error { } else { dname = m.Name() + "." + fieldName } + var tname string + switch m.Type() { + case telegraf.Counter: + tname = "count" + case telegraf.Gauge: + tname = "gauge" + default: + tname = "" + } metric := &Metric{ - Metric: dname, - Tags: metricTags, - Host: host, + Metric: dname, + Tags: metricTags, + Host: host, + Type: tname, + Interval: 1, } metric.Points[0] = dogM tempSeries = append(tempSeries, metric)