From 29c3a905da642970c61a9521c358d0f3767a172d Mon Sep 17 00:00:00 2001 From: Edie Zhang Date: Fri, 7 Oct 2016 11:47:23 +1100 Subject: [PATCH] adding the tags in the graylog output plugin closes #1861 --- CHANGELOG.md | 1 + plugins/outputs/graylog/graylog.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2aaeba55540c..93162e67e73df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ continue sending logs to /var/log/telegraf/telegraf.log. ### Features +- [#1861](https://github.com/influxdata/telegraf/pull/1861): adding the tags in the graylog output plugin - [#1732](https://github.com/influxdata/telegraf/pull/1732): Telegraf systemd service, log to journal. - [#1782](https://github.com/influxdata/telegraf/pull/1782): Allow numeric and non-string values for tag_keys. - [#1694](https://github.com/influxdata/telegraf/pull/1694): Adding Gauge and Counter metric types. diff --git a/plugins/outputs/graylog/graylog.go b/plugins/outputs/graylog/graylog.go index 7f2480134f892..64624bcb40474 100644 --- a/plugins/outputs/graylog/graylog.go +++ b/plugins/outputs/graylog/graylog.go @@ -226,9 +226,14 @@ func serialize(metric telegraf.Metric) ([]string, error) { m["host"] = host } + for key, value := range metric.Tags() { + if key != "host" { + m["_"+key] = value + } + } + for key, value := range metric.Fields() { - nkey := fmt.Sprintf("_%s", key) - m[nkey] = value + m["_"+key] = value } serialized, err := ejson.Marshal(m)