From 6f002ecf334b6fa876c8e8b2e3190f01e90ad506 Mon Sep 17 00:00:00 2001 From: G-regL Date: Thu, 28 Apr 2016 13:12:04 -0400 Subject: [PATCH] Sanitize Field name Replace '/[sS]ec' for '_persec' and spaces with underscores. --- plugins/inputs/win_perf_counters/win_perf_counters.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/win_perf_counters/win_perf_counters.go b/plugins/inputs/win_perf_counters/win_perf_counters.go index 8279f1c7a..4684289ee 100644 --- a/plugins/inputs/win_perf_counters/win_perf_counters.go +++ b/plugins/inputs/win_perf_counters/win_perf_counters.go @@ -107,6 +107,8 @@ type item struct { counterHandle win.PDH_HCOUNTER } +var sanitizedChars = strings.NewReplacer("/sec", "_persec", "/Sec", "_persec", " ", "_") + func (m *Win_PerfCounters) AddItem(metrics *itemList, query string, objectName string, counter string, instance string, measurement string, include_total bool) { @@ -297,7 +299,7 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error { tags["instance"] = s } tags["objectname"] = metric.objectName - fields[string(metric.counter)] = float32(c.FmtValue.DoubleValue) + fields[sanitizedChars.Replace(string(metric.counter))] = float32(c.FmtValue.DoubleValue) var measurement string if metric.measurement == "" {