From 4bcf157d88ac484b842c4b20081b7387fa9755d3 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 19 Apr 2016 22:50:22 -0600 Subject: [PATCH] Don't replace _ with . in datadog names closes #1024 --- CHANGELOG.md | 2 ++ plugins/outputs/datadog/datadog.go | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba75be262f5b9..a652b38d767be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ for more details. only. Previously there was an undocumented behavior where filters would match based on _prefix_ in addition to globs. This means that a filter like `fielddrop = ["time_"]` will need to be changed to `fielddrop = ["time_*"]` +- **datadog**: measurement and field names will no longer have `_` replaced by `.` - The following plugins have changed their tags to _not_ overwrite the host tag: - cassandra: `host -> cassandra_host` - disque: `host -> disque_host` @@ -42,6 +43,7 @@ based on _prefix_ in addition to globs. This means that a filter like - [#921](https://github.com/influxdata/telegraf/pull/921): mqtt_consumer stops gathering metrics. Thanks @chaton78! - [#1013](https://github.com/influxdata/telegraf/pull/1013): Close dead riemann output connections. Thanks @echupriyanov! - [#1012](https://github.com/influxdata/telegraf/pull/1012): Set default tags in test accumulator. +- [#1024](https://github.com/influxdata/telegraf/issues/1024): Don't replace `.` with `_` in datadog output. - [#1058](https://github.com/influxdata/telegraf/issues/1058): Fix possible leaky TCP connections in influxdb output. - [#1044](https://github.com/influxdata/telegraf/pull/1044): Fix SNMP OID possible collisions. Thanks @relip diff --git a/plugins/outputs/datadog/datadog.go b/plugins/outputs/datadog/datadog.go index 56fdc38e40919..0885687181c09 100644 --- a/plugins/outputs/datadog/datadog.go +++ b/plugins/outputs/datadog/datadog.go @@ -8,7 +8,6 @@ import ( "net/http" "net/url" "sort" - "strings" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" @@ -71,21 +70,22 @@ func (d *Datadog) Write(metrics []telegraf.Metric) error { metricCounter := 0 for _, m := range metrics { - mname := strings.Replace(m.Name(), "_", ".", -1) if dogMs, err := buildMetrics(m); err == nil { for fieldName, dogM := range dogMs { // name of the datadog measurement var dname string if fieldName == "value" { // adding .value seems redundant here - dname = mname + dname = m.Name() } else { - dname = mname + "." + strings.Replace(fieldName, "_", ".", -1) + dname = m.Name() + "." + fieldName } + var host string + host, _ = m.Tags()["host"] metric := &Metric{ Metric: dname, Tags: buildTags(m.Tags()), - Host: m.Tags()["host"], + Host: host, } metric.Points[0] = dogM tempSeries = append(tempSeries, metric)