Skip to content

Added user label to cortex_ingester_memory_series metric #1811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. #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`
Expand Down
10 changes: 6 additions & 4 deletions pkg/ingester/user_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -62,6 +62,7 @@ type userState struct {

seriesInMetric []metricCounterShard

memSeries prometheus.Gauge
memSeriesCreatedTotal prometheus.Counter
memSeriesRemovedTotal prometheus.Counter
discardedSamples *prometheus.CounterVec
Expand Down Expand Up @@ -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}),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down