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 a6de4577b0
commit 7ef88c4bf9
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