From 93d17ec95e2ae3090345564a017ebd67c7548cfa Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 15 May 2018 15:54:20 -0700 Subject: [PATCH] Fix librato output support for uint and bool (#4151) --- plugins/outputs/librato/librato.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/outputs/librato/librato.go b/plugins/outputs/librato/librato.go index 244e8bd59..0603394ec 100644 --- a/plugins/outputs/librato/librato.go +++ b/plugins/outputs/librato/librato.go @@ -107,7 +107,6 @@ func (l *Librato) Write(metrics []telegraf.Metric) error { for _, gauge := range gauges { tempGauges = append(tempGauges, gauge) log.Printf("D! Got a gauge: %v\n", gauge) - } } else { log.Printf("I! unable to build Gauge for %s, skipping\n", m.Name()) @@ -234,16 +233,18 @@ func verifyValue(v interface{}) bool { func (g *Gauge) setValue(v interface{}) error { switch d := v.(type) { - case int: - g.Value = float64(int(d)) - case int32: - g.Value = float64(int32(d)) case int64: g.Value = float64(int64(d)) - case float32: + case uint64: g.Value = float64(d) case float64: g.Value = float64(d) + case bool: + if d { + g.Value = float64(1.0) + } else { + g.Value = float64(0.0) + } default: return fmt.Errorf("undeterminable type %+v", d) }