diff --git a/metricbeat/helper/prometheus/prometheus_test.go b/metricbeat/helper/prometheus/prometheus_test.go index 2c23a119ff8a..00d98eb94f2c 100644 --- a/metricbeat/helper/prometheus/prometheus_test.go +++ b/metricbeat/helper/prometheus/prometheus_test.go @@ -1242,7 +1242,7 @@ cc_seconds_created 123.456` info := `# TYPE info_metric info # HELP info_metric help -info_metric{foo="bar"} 1 2` +info_metric_info{foo="bar"} 1 2` infoMetricFamily := MetricFamily{ Name: stringp("info_metric"), Help: stringp("help"), @@ -1256,7 +1256,7 @@ info_metric{foo="bar"} 1 2` Value: "bar", }, }, - Name: stringp("info_metric"), + Name: stringp("info_metric_info"), Info: &Info{ Value: int64p(1), }, diff --git a/metricbeat/helper/prometheus/textparse.go b/metricbeat/helper/prometheus/textparse.go index 014016df434a..a670fac866c8 100644 --- a/metricbeat/helper/prometheus/textparse.go +++ b/metricbeat/helper/prometheus/textparse.go @@ -325,6 +325,7 @@ const ( suffixSum = "_sum" suffixBucket = "_bucket" suffixCreated = "_created" + suffixInfo = "_info" ) // Counters have _total suffix @@ -604,7 +605,8 @@ func ParseMetricFamilies(b []byte, contentType string, ts time.Time) ([]*MetricF value := int64(v) var info = &Info{Value: &value} metric = &OpenMetric{Name: &metricName, Info: info, Label: labelPairs} - lookupMetricName = metricName + // remove the _info suffix + lookupMetricName = strings.TrimSuffix(metricName, suffixInfo) case textparse.MetricTypeSummary: lookupMetricName, metric = summaryMetricName(metricName, v, qv, lbls.String(), summariesByName) metric.Label = labelPairs @@ -654,7 +656,8 @@ func ParseMetricFamilies(b []byte, contentType string, ts time.Time) ([]*MetricF fam, ok = metricFamiliesByName[lookupMetricName] if !ok { - fam = &MetricFamily{Type: mt} + // If the family metric does not exist, create a new one with the lookup name + fam = &MetricFamily{Name: &lookupMetricName, Type: mt} metricFamiliesByName[lookupMetricName] = fam }