From f4d802d9a81ff50c972c52c127448fe5f0b1fba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20H=C3=A9bert?= Date: Tue, 9 Aug 2016 11:53:42 +0200 Subject: [PATCH] Update code style --- plugins/outputs/warp10/README.md | 7 +++---- plugins/outputs/warp10/warp10.go | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/outputs/warp10/README.md b/plugins/outputs/warp10/README.md index 0fa077d5e..b42a91e10 100644 --- a/plugins/outputs/warp10/README.md +++ b/plugins/outputs/warp10/README.md @@ -4,19 +4,18 @@ Telegraph plugin to push metrics on Warp10 ### Telegraph output for Warp10 ### -* Execute a post http on Warp10 at every flush time configured in telegraph in order to push the metrics collected +Execute a post http on Warp10 at every flush time configured in telegraph in order to push the metrics collected ### Config ### -* Add following instruction in the config file (Output part) +Add following instruction in the config file (Output part) ``` [[outputs.warp10]] -warpUrl = "https://warp1.cityzendata.net/api/v0/update" +warpUrl = "http://localhost:4242" token = "token" prefix = "telegraf." debug = false - ``` ### Contact ### diff --git a/plugins/outputs/warp10/warp10.go b/plugins/outputs/warp10/warp10.go index 83e32af20..a1071d997 100755 --- a/plugins/outputs/warp10/warp10.go +++ b/plugins/outputs/warp10/warp10.go @@ -24,10 +24,10 @@ type Warp10 struct { var sampleConfig = ` # prefix for metrics class Name - prefix = "telegraf." - ## POST HTTP Mode ## + prefix = "Prefix" + ## POST HTTP(or HTTPS) ## # Url name of the Warp 10 server - warp_url = "localhost:4242/" + warp_url = "WarpUrl" # Token to access your app on warp 10 token = "Token" ` @@ -47,7 +47,7 @@ func (o *Warp10) Write(metrics []telegraf.Metric) error { if len(metrics) == 0 { return nil } - var timeNow = time.Now() + var now = time.Now() collectString := make([]string, 0) index := 0 for _, mm := range metrics { @@ -56,20 +56,20 @@ func (o *Warp10) Write(metrics []telegraf.Metric) error { metric := &MetricLine{ Metric: fmt.Sprintf("%s%s", o.Prefix, mm.Name()+"."+k), - Timestamp: timeNow.Unix() * 1000000, + Timestamp: now.Unix() * 1000000, } - metricValue, buildError := buildValue(v) - if buildError != nil { - fmt.Printf("Warp: %s\n", buildError.Error()) + metricValue, err := buildValue(v) + if err != nil { + log.Printf("Warp: %s\n", err.Error()) continue } metric.Value = metricValue tagsSlice := buildTags(mm.Tags()) - metric.Tags = fmt.Sprint(strings.Join(tagsSlice, ",")) + metric.Tags = strings.Join(tagsSlice, ",") - messageLine := fmt.Sprintf("%v// %s{%s} %v \n", metric.Timestamp, metric.Metric, metric.Tags, metric.Value) + messageLine := fmt.Sprintf("%d// %s{%s} %s\n", metric.Timestamp, metric.Metric, metric.Tags, metric.Value) collectString = append(collectString, messageLine) index += 1