Use labels in prometheus output for string fields (#3350)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user