Use labels in prometheus output for string fields (#3350)

This commit is contained in:
Daniel Nelson
2017-10-18 17:42:30 -07:00
committed by GitHub
parent adb1f5588c
commit ec4efe5b03
2 changed files with 37 additions and 0 deletions

View File

@@ -242,6 +242,15 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
labels[sanitize(k)] = v
}
// Prometheus doesn't have a string value type, so convert string
// fields to labels.
for fn, fv := range point.Fields() {
switch fv := fv.(type) {
case string:
labels[sanitize(fn)] = fv
}
}
for fn, fv := range point.Fields() {
// Ignore string and bool fields.
var value float64