Skip to content

nri-prom histogram improvement: add _count counter by default #1890

Open
@jackwilsdon

Description

Description

The _count counter is not included in data pushed to New Relic for Prometheus histograms.

Expected Behavior

The _count counter should be included.

Steps to Reproduce

Scrape a Prometheus histogram with the infrastructure agent and nri-prometheus. Note that the _count counter is not exported to New Relic.

Additional context

The summary type already has support for _count:

metricName = metric.Name + "_count"
countMetric, ok := p.calculate.get(metricName, metric.Attributes, value.SampleCount, metric.Time())
if ok {
result = append(result, countMetric)
} else {
telemetryLogger.WithField("name", metricName).WithField("metric-type", metric.Type).Debug(noCalculationMadeErrMsg)
}

But it looks like the histogram type doesn't:

metricName := metric.Name + "_sum"
sumCount, ok := ph.calculate.get(metricName, metric.Attributes, float64(*value.SampleCount), metric.Time())
if ok {
result = append(result, telemetry.Summary{
Name: metricName,
Attributes: metric.Attributes,
Count: 1,
Sum: sumCount.Value,
Min: math.NaN(),
Max: math.NaN(),
Timestamp: metric.Time(),
Interval: sumCount.Interval,
})
} else {
telemetryLogger.WithField("name", metricName).WithField("metric-type", metric.Type).Debug(noCalculationMadeErrMsg)
}
metricName = metric.Name + "_bucket"
for _, b := range value.Buckets {
bucketAttrs := metric.CopyAttrs()
bucketAttrs["le"] = fmt.Sprintf("%g", *b.UpperBound)
bucketCount, ok := ph.calculate.get(
metricName,
bucketAttrs,
float64(*b.CumulativeCount),
metric.Time(),
)
if ok {
result = append(result, bucketCount)
} else {
telemetryLogger.WithField("name", metricName).WithField("metric-type", metric.Type).Debug(noCalculationMadeErrMsg)
}
}

For Maintainers Only or Hero Triaging this bug

Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):

Metadata

Assignees

No one assigned

    Labels

    bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions