From ea11fae57b2afc8421216d61a8833785002e19ea Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Mon, 2 Oct 2017 20:42:21 -0400 Subject: [PATCH] Added newline to each metric line in wavefront output (#3290) --- plugins/outputs/wavefront/wavefront.go | 4 +++- plugins/outputs/wavefront/wavefront_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/outputs/wavefront/wavefront.go b/plugins/outputs/wavefront/wavefront.go index 773e970bc..85a73e319 100644 --- a/plugins/outputs/wavefront/wavefront.go +++ b/plugins/outputs/wavefront/wavefront.go @@ -124,7 +124,7 @@ func (w *Wavefront) Write(metrics []telegraf.Metric) error { for _, m := range metrics { for _, metricPoint := range buildMetrics(m, w) { metricLine := formatMetricPoint(metricPoint, w) - //log.Printf("D! Output [wavefront] %s", metricLine) + log.Printf("D! Output [wavefront] %s", metricLine) _, err := connection.Write([]byte(metricLine)) if err != nil { return fmt.Errorf("Wavefront: TCP writing error %s", err.Error()) @@ -262,6 +262,8 @@ func formatMetricPoint(metricPoint *MetricPoint, w *Wavefront) string { buffer.WriteString("\"") } + buffer.WriteString("\n") + return buffer.String() } diff --git a/plugins/outputs/wavefront/wavefront_test.go b/plugins/outputs/wavefront/wavefront_test.go index 1dd4d7078..f1722e668 100644 --- a/plugins/outputs/wavefront/wavefront_test.go +++ b/plugins/outputs/wavefront/wavefront_test.go @@ -275,7 +275,7 @@ func TestFormatMetricPoint(t *testing.T) { Tags: map[string]string{"sp*c!@l\"-ch/rs": "sp*c!@l/ val\"ue"}, } - expected := "test.metric.something 123.456000 1257894000 source=\"testSource\" sp-c--l--ch-rs=\"sp-c!@l/ val\\\"ue\"" + expected := "test.metric.something 123.456000 1257894000 source=\"testSource\" sp-c--l--ch-rs=\"sp-c!@l/ val\\\"ue\"\n" received := formatMetricPoint(testpoint, w)