Sanitize Field name

Replace '/[sS]ec' for '_persec' and spaces with underscores.
This commit is contained in:
G-regL 2016-04-28 13:12:04 -04:00
parent 13c4aef197
commit 6f002ecf33
1 changed files with 3 additions and 1 deletions

View File

@ -107,6 +107,8 @@ type item struct {
counterHandle win.PDH_HCOUNTER 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, func (m *Win_PerfCounters) AddItem(metrics *itemList, query string, objectName string, counter string, instance string,
measurement string, include_total bool) { measurement string, include_total bool) {
@ -297,7 +299,7 @@ func (m *Win_PerfCounters) Gather(acc telegraf.Accumulator) error {
tags["instance"] = s tags["instance"] = s
} }
tags["objectname"] = metric.objectName 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 var measurement string
if metric.measurement == "" { if metric.measurement == "" {