Skip to content

Commit

Permalink
receiver/prometheus: add _total to list of trimmable metric name su…
Browse files Browse the repository at this point in the history
…ffixes (#3603)

**Description:** attempts to ensure that the prometheus receiver correctly ingests counter metrics, regardless whether the producing system includes a `_total` suffix on the counter metric name.

**Fixes:** #3557 

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
  • Loading branch information
Aneurysm9 authored Jul 13, 2021
1 parent ad8ae26 commit 79816e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion receiver/prometheusreceiver/internal/metricsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ const (
metricsSuffixCount = "_count"
metricsSuffixBucket = "_bucket"
metricsSuffixSum = "_sum"
metricSuffixTotal = "_total"
startTimeMetricName = "process_start_time_seconds"
scrapeUpMetricName = "up"
)

var (
trimmableSuffixes = []string{metricsSuffixBucket, metricsSuffixCount, metricsSuffixSum}
trimmableSuffixes = []string{metricsSuffixBucket, metricsSuffixCount, metricsSuffixSum, metricSuffixTotal}
errNoDataToBuild = errors.New("there's no data to build")
errNoBoundaryLabel = errors.New("given metricType has no BucketLabel or QuantileLabel")
errEmptyBoundaryLabel = errors.New("BucketLabel or QuantileLabel is empty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,7 @@ func Test_normalizeMetricName(t *testing.T) {
{"count", "foo_count", "foo"},
{"bucket", "foo_bucket", "foo"},
{"sum", "foo_sum", "foo"},
{"total", "foo_total", "foo"},
{"no_prefix", "_sum", "_sum"},
}
for _, tt := range tests {
Expand Down

0 comments on commit 79816e7

Please sign in to comment.