diff --git a/plugins/outputs/opentsdb/opentsdb.go b/plugins/outputs/opentsdb/opentsdb.go index 766c7a304d75b..ae1e2a5362bc5 100644 --- a/plugins/outputs/opentsdb/opentsdb.go +++ b/plugins/outputs/opentsdb/opentsdb.go @@ -3,6 +3,7 @@ package opentsdb import ( "fmt" "log" + "math" "net" "net/url" "regexp" @@ -136,10 +137,14 @@ func (o *OpenTSDB) WriteHttp(metrics []telegraf.Metric, u *url.URL) error { tags := cleanTags(m.Tags()) for fieldName, value := range m.Fields() { - switch value.(type) { + switch fv := value.(type) { case int64: case uint64: case float64: + // JSON does not support these special values + if math.IsNaN(fv) || math.IsInf(fv, 0) { + continue + } default: log.Printf("D! OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value) continue @@ -181,10 +186,14 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error { tags := ToLineFormat(cleanTags(m.Tags())) for fieldName, value := range m.Fields() { - switch value.(type) { + switch fv := value.(type) { case int64: case uint64: case float64: + // JSON does not support these special values + if math.IsNaN(fv) || math.IsInf(fv, 0) { + continue + } default: log.Printf("D! OpenTSDB does not support metric value: [%s] of type [%T].\n", value, value) continue