diff --git a/metricbeat/module/prometheus/collector/collector_test.go b/metricbeat/module/prometheus/collector/collector_test.go index ef52c114fe1..362ae0a137b 100644 --- a/metricbeat/module/prometheus/collector/collector_test.go +++ b/metricbeat/module/prometheus/collector/collector_test.go @@ -120,7 +120,7 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) { "http_request_duration_microseconds": float64(10), }, labels: common.MapStr{ - "quantile": float64(0.99), + "quantile": "0.99", }, }, }, @@ -157,7 +157,7 @@ func TestGetPromEventsFromMetricFamily(t *testing.T) { data: common.MapStr{ "http_request_duration_microseconds": uint64(10), }, - labels: common.MapStr{"le": float64(0.99)}, + labels: common.MapStr{"le": "0.99"}, }, }, }, diff --git a/metricbeat/module/prometheus/collector/data.go b/metricbeat/module/prometheus/collector/data.go index 3073d2a03c0..0120aa55db3 100644 --- a/metricbeat/module/prometheus/collector/data.go +++ b/metricbeat/module/prometheus/collector/data.go @@ -19,6 +19,7 @@ package collector import ( "math" + "strconv" "github.com/elastic/beats/libbeat/common" @@ -88,7 +89,7 @@ func getPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent { } quantileLabels := labels.Clone() - quantileLabels["quantile"] = quantile.GetQuantile() + quantileLabels["quantile"] = strconv.FormatFloat(quantile.GetQuantile(), 'f', -1, 64) events = append(events, PromEvent{ data: common.MapStr{ name: quantile.GetValue(), @@ -110,8 +111,7 @@ func getPromEventsFromMetricFamily(mf *dto.MetricFamily) []PromEvent { for _, bucket := range histogram.GetBucket() { bucketLabels := labels.Clone() - // XXX 0 == +Inf? - bucketLabels["le"] = bucket.GetUpperBound() + bucketLabels["le"] = strconv.FormatFloat(bucket.GetUpperBound(), 'f', -1, 64) events = append(events, PromEvent{ data: common.MapStr{