From 555fc815a22d66fd802c15e4bf013aaf75876bbc Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Tue, 12 Nov 2019 08:43:46 +0100 Subject: [PATCH 1/2] Added user label to cortex_ingester_memory_series metric Signed-off-by: Marco Pracucci --- CHANGELOG.md | 1 + pkg/ingester/user_state.go | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e2d1bf09f..3c8ef14d14d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * [CHANGE] Removed `Delta` encoding. Any old chunks with `Delta` encoding cannot be read anymore. If `ingester.chunk-encoding` is set to `Delta` the ingester will fail to start. #1706 * [CHANGE] Setting `-ingester.max-transfer-retries` to 0 now disables hand-over when ingester is shutting down. Previously, zero meant infinite number of attempts. #1771 * [CHANGE] `dynamo` has been removed as a valid storage name to make it consistent for all components. `aws` and `aws-dynamo` remain as valid storage names. +* [CHANGE] Added `user` label to `cortex_ingester_memory_series` metric. * [FEATURE] Global limit on the max series per user and metric #1760 * `-ingester.max-global-series-per-user` * `-ingester.max-global-series-per-metric` diff --git a/pkg/ingester/user_state.go b/pkg/ingester/user_state.go index e27d68411fd..301e6f7fe37 100644 --- a/pkg/ingester/user_state.go +++ b/pkg/ingester/user_state.go @@ -24,10 +24,10 @@ import ( ) var ( - memSeries = promauto.NewGauge(prometheus.GaugeOpts{ + memSeries = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "cortex_ingester_memory_series", Help: "The current number of series in memory.", - }) + }, []string{"user"}) memUsers = promauto.NewGauge(prometheus.GaugeOpts{ Name: "cortex_ingester_memory_users", Help: "The current number of users in memory.", @@ -62,6 +62,7 @@ type userState struct { seriesInMetric []metricCounterShard + memSeries prometheus.Gauge memSeriesCreatedTotal prometheus.Counter memSeriesRemovedTotal prometheus.Counter discardedSamples *prometheus.CounterVec @@ -157,6 +158,7 @@ func (us *userStates) getOrCreateSeries(ctx context.Context, userID string, labe ingestedRuleSamples: newEWMARate(0.2, us.cfg.RateUpdatePeriod), seriesInMetric: seriesInMetric, + memSeries: memSeries.WithLabelValues(userID), memSeriesCreatedTotal: memSeriesCreatedTotal.WithLabelValues(userID), memSeriesRemovedTotal: memSeriesRemovedTotal.WithLabelValues(userID), discardedSamples: validation.DiscardedSamples.MustCurryWith(prometheus.Labels{"user": userID}), @@ -214,7 +216,7 @@ func (u *userState) getSeries(metric labelPairs) (model.Fingerprint, *memorySeri } u.memSeriesCreatedTotal.Inc() - memSeries.Inc() + u.memSeries.Inc() labels := u.index.Add(metric, fp) series = newMemorySeries(labels) @@ -258,7 +260,7 @@ func (u *userState) removeSeries(fp model.Fingerprint, metric labels.Labels) { } u.memSeriesRemovedTotal.Inc() - memSeries.Dec() + u.memSeries.Dec() } // forSeriesMatching passes all series matching the given matchers to the From cea12aaa76dd881d340cbe991ba7fabda2fe3435 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Tue, 12 Nov 2019 08:58:28 +0100 Subject: [PATCH 2/2] Added PR number to changelog entry Signed-off-by: Marco Pracucci --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c8ef14d14d..3e4a62eff47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * [CHANGE] Removed `Delta` encoding. Any old chunks with `Delta` encoding cannot be read anymore. If `ingester.chunk-encoding` is set to `Delta` the ingester will fail to start. #1706 * [CHANGE] Setting `-ingester.max-transfer-retries` to 0 now disables hand-over when ingester is shutting down. Previously, zero meant infinite number of attempts. #1771 * [CHANGE] `dynamo` has been removed as a valid storage name to make it consistent for all components. `aws` and `aws-dynamo` remain as valid storage names. -* [CHANGE] Added `user` label to `cortex_ingester_memory_series` metric. +* [CHANGE] Added `user` label to `cortex_ingester_memory_series` metric. #1811 * [FEATURE] Global limit on the max series per user and metric #1760 * `-ingester.max-global-series-per-user` * `-ingester.max-global-series-per-metric`