Skip to content

Commit 3482bef

Browse files
authored
Export cortex_attributed_series_overflow_labels (#12846)
<!-- Thanks for sending a pull request! Before submitting: 1. Read our CONTRIBUTING.md guide 2. Rebase your PR if it gets out of sync with main --> #### What this PR does Exports a new constant metric `cortex_attributed_series_overflow_labels ` with the configured cost-attribution labels set to overflow values. #### Which issue(s) this PR fixes or relates to Fixes needs in the billing pipeline. #### Checklist - [x] Tests updated. - [ ] Documentation added. - [x] `CHANGELOG.md` updated - the order of entries should be `[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry is not needed, please add the `changelog-not-needed` label to the PR. - [ ] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features. --------- Signed-off-by: Oleg Zaytsev <[email protected]>
1 parent 97511d4 commit 3482bef

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
* [ENHANCEMENT] Compactor: Log sizes of downloaded and uploaded blocks. #12656
6767
* [ENHANCEMENT] Ingester: Add `cortex_ingest_storage_reader_receive_and_consume_delay_seconds` metric tracking the time between when a write request is received in the distributor and its content is ingested in ingesters, when the ingest storage is enabled. #12751
6868
* [ENHANCEMENT] Ruler: Add `ruler_evaluation_consistency_max_delay` per-tenant configuration option support, to specify the maximum tolerated ingestion delay for eventually consistent rule evaluations. This feature is used only when ingest storage is enabled. By default, no maximum delay is enforced. #12751
69+
* [ENHANCEMENT] Ingester: Export `cortex_attributed_series_overflow_labels` metric on the `/usage-metrics` metrics endpoint with the configured cost-attribution labels set to overflow value. #12846
6970
* [BUGFIX] Distributor: Calculate `WriteResponseStats` before validation and `PushWrappers`. This prevents clients using Remote-Write 2.0 from seeing a diff in written samples, histograms and exemplars. #12682
7071
* [BUGFIX] Compactor: Fix cortex_compactor_block_uploads_failed_total metric showing type="unknown". #12477
7172
* [BUGFIX] Querier: Samples with the same timestamp are merged deterministically. Previously, this could lead to flapping query results when an out-of-order sample is ingested that conflicts with a previously ingested in-order sample's value. #8673

pkg/costattribution/active_tracker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type counters struct {
2929
type ActiveSeriesTracker struct {
3030
userID string
3131
activeSeriesPerUserAttribution *prometheus.Desc
32+
attributedOverflowLabels *prometheus.Desc
3233
activeNativeHistogramSeriesPerUserAttribution *prometheus.Desc
3334
activeNativeHistogramBucketsPerUserAttribution *prometheus.Desc
3435
logger log.Logger
@@ -77,6 +78,9 @@ func NewActiveSeriesTracker(userID string, trackedLabels []costattributionmodel.
7778
ast.activeSeriesPerUserAttribution = prometheus.NewDesc("cortex_ingester_attributed_active_series",
7879
"The total number of active series per user and attribution.", variableLabels[:len(variableLabels)-1],
7980
prometheus.Labels{trackerLabel: defaultTrackerName})
81+
ast.attributedOverflowLabels = prometheus.NewDesc("cortex_attributed_series_overflow_labels",
82+
"The overflow labels for this tenant. This metric is always 1 for tenants with active series, it is only used to have the overflow labels available in the recording rules without knowing their names.", variableLabels[:len(variableLabels)-1],
83+
prometheus.Labels{trackerLabel: defaultTrackerName})
8084
ast.activeNativeHistogramSeriesPerUserAttribution = prometheus.NewDesc("cortex_ingester_attributed_active_native_histogram_series",
8185
"The total number of active native histogram series per user and attribution.", variableLabels[:len(variableLabels)-1],
8286
prometheus.Labels{trackerLabel: defaultTrackerName})
@@ -213,6 +217,8 @@ func (at *ActiveSeriesTracker) Decrement(lbls labels.Labels, nativeHistogramBuck
213217
}
214218

215219
func (at *ActiveSeriesTracker) Collect(out chan<- prometheus.Metric) {
220+
out <- prometheus.MustNewConstMetric(at.attributedOverflowLabels, prometheus.GaugeValue, 1, at.overflowLabels[:len(at.overflowLabels)-1]...)
221+
216222
at.observedMtx.RLock()
217223
if !at.overflowSince.IsZero() {
218224
var activeSeries int64

pkg/costattribution/manager_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func TestManager_CreateDeleteTracker(t *testing.T) {
8080
# HELP cortex_ingester_attributed_active_series The total number of active series per user and attribution.
8181
# TYPE cortex_ingester_attributed_active_series gauge
8282
cortex_ingester_attributed_active_series{team="bar",tenant="user1",tracker="cost-attribution"} 3
83+
# HELP cortex_attributed_series_overflow_labels The overflow labels for this tenant. This metric is always 1 for tenants with active series, it is only used to have the overflow labels available in the recording rules without knowing their names.
84+
# TYPE cortex_attributed_series_overflow_labels gauge
85+
cortex_attributed_series_overflow_labels{team="__overflow__",tenant="user1",tracker="cost-attribution"} 1
86+
cortex_attributed_series_overflow_labels{department="__overflow__",service="__overflow__",tenant="user3",tracker="cost-attribution"} 1
8387
`
8488
assert.NoError(t, testutil.GatherAndCompare(costAttributionReg,
8589
strings.NewReader(expectedMetrics),
@@ -88,6 +92,7 @@ func TestManager_CreateDeleteTracker(t *testing.T) {
8892
"cortex_ingester_attributed_active_series",
8993
"cortex_ingester_attributed_active_native_histogram_series",
9094
"cortex_ingester_attributed_active_native_histogram_buckets",
95+
"cortex_attributed_series_overflow_labels",
9196
))
9297

9398
manager.ActiveSeriesTracker("user1").Decrement(labels.FromStrings("team", "bar"), 50)

0 commit comments

Comments
 (0)