Converge to typed value in prometheus output (#3104)

This commit is contained in:
Daniel Nelson
2017-08-10 10:19:28 -07:00
committed by GitHub
parent b1eb240b18
commit 294b7322b4
2 changed files with 61 additions and 1 deletions

View File

@@ -254,7 +254,17 @@ func (p *PrometheusClient) Write(metrics []telegraf.Metric) error {
}
p.fam[mname] = fam
} else {
if fam.ValueType != vt {
// Metrics can be untyped even though the corresponding plugin
// creates them with a type. This happens when the metric was
// transferred over the network in a format that does not
// preserve value type and received using an input such as a
// queue consumer. To avoid issues we automatically upgrade
// value type from untyped to a typed metric.
if fam.ValueType == prometheus.UntypedValue {
fam.ValueType = vt
}
if vt != prometheus.UntypedValue && fam.ValueType != vt {
// Don't return an error since this would be a permanent error
log.Printf("Mixed ValueType for measurement %q; dropping point", point.Name())
break