From 3e3b09427027fc8ead2ee28be5bf36974c337663 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 21 Sep 2016 10:29:22 -0400 Subject: [PATCH] Only log warning on type when in debug mode. closes #1793 --- CHANGELOG.md | 1 + plugins/outputs/opentsdb/opentsdb.go | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 984f1c0c9..8a054d392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ continue sending logs to /var/log/telegraf/telegraf.log. - [#1835](https://github.com/influxdata/telegraf/issues/1835): Fix SNMP emitting empty fields. - [#1854](https://github.com/influxdata/telegraf/pull/1853): SQL Server waitstats truncation bug. - [#1810](https://github.com/influxdata/telegraf/issues/1810): Fix logparser common log format: numbers in ident. +- [#1793](https://github.com/influxdata/telegraf/pull/1793): Fix JSON Serialization in OpenTSDB output. ## v1.0.1 [2016-09-26] diff --git a/plugins/outputs/opentsdb/opentsdb.go b/plugins/outputs/opentsdb/opentsdb.go index b3d9b4997..232edc0b7 100644 --- a/plugins/outputs/opentsdb/opentsdb.go +++ b/plugins/outputs/opentsdb/opentsdb.go @@ -2,6 +2,7 @@ package opentsdb import ( "fmt" + "log" "net" "net/url" "sort" @@ -114,7 +115,7 @@ func (o *OpenTSDB) WriteHttp(metrics []telegraf.Metric, u *url.URL) error { case uint64: case float64: default: - fmt.Printf("OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value) + log.Printf("D! OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value) continue } @@ -156,7 +157,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error { for fieldName, value := range m.Fields() { metricValue, buildError := buildValue(value) if buildError != nil { - fmt.Printf("OpenTSDB: %s\n", buildError.Error()) + log.Printf("E! OpenTSDB: %s\n", buildError.Error()) continue } @@ -164,9 +165,6 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error { sanitizedChars.Replace(fmt.Sprintf("%s%s_%s", o.Prefix, m.Name(), fieldName)), now, metricValue, tags) - if o.Debug { - fmt.Print(messageLine) - } _, err := connection.Write([]byte(messageLine)) if err != nil { return fmt.Errorf("OpenTSDB: Telnet writing error %s", err.Error())