Skip to content

Commit

Permalink
usage stats: report active series (#8279)
Browse files Browse the repository at this point in the history
* usage stats: report active series

Usage stats already include in-memory series. This PR also adds active series to reports. Active series give information closer to the users' needs, whereas in-memory series are more related to how the system handles load. Active series in combination with in-memory series also help estimate churn.

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

* Add CHANGELOG.md entry

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

* Update docs

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

---------

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
  • Loading branch information
dimitarvdimitrov authored Jun 6, 2024
1 parent 14afae0 commit 2ec3b86
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [CHANGE] Query-frontend: stop using `-validation.create-grace-period` to clamp how far into the future a query can span.
* [CHANGE] Clamp [`GOMAXPROCS`](https://pkg.go.dev/runtime#GOMAXPROCS) to [`runtime.NumCPU`](https://pkg.go.dev/runtime#NumCPU). #8201
* [CHANGE] Added new metric `cortex_compactor_disk_out_of_space_errors_total` which counts how many times a compaction failed due to the compactor being out of disk. #8237
* [CHANGE] Anonymous usage statistics tracking: report active series in addition to in-memory series. #8279
* [FEATURE] Continuous-test: now runable as a module with `mimir -target=continuous-test`. #7747
* [FEATURE] Store-gateway: Allow specific tenants to be enabled or disabled via `-store-gateway.enabled-tenants` or `-store-gateway.disabled-tenants` CLI flags or their corresponding YAML settings. #7653
* [FEATURE] New `-<prefix>.s3.bucket-lookup-type` flag configures lookup style type, used to access bucket in s3 compatible providers. #7684
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ When the usage statistics reporting is enabled, Grafana Mimir collects the follo
- Information about the Mimir **cluster scale**:
- Ingester:
- The number of in-memory series.
- The number of active series.
- The number of tenants that have in-memory series.
- The number of tenants that have out-of-order ingestion enabled.
- The number of samples and exemplars ingested.
Expand Down
7 changes: 7 additions & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const (
replicationFactorStatsName = "ingester_replication_factor"
ringStoreStatsName = "ingester_ring_store"
memorySeriesStatsName = "ingester_inmemory_series"
activeSeriesStatsName = "ingester_active_series"
memoryTenantsStatsName = "ingester_inmemory_tenants"
appendedSamplesStatsName = "ingester_appended_samples"
appendedExemplarsStatsName = "ingester_appended_exemplars"
Expand Down Expand Up @@ -138,6 +139,7 @@ var (
// updated in Ingester.updateUsageStats.
memorySeriesStats = usagestats.GetAndResetInt(memorySeriesStatsName)
memoryTenantsStats = usagestats.GetAndResetInt(memoryTenantsStatsName)
activeSeriesStats = usagestats.GetAndResetInt(activeSeriesStatsName)
tenantsWithOutOfOrderEnabledStat = usagestats.GetAndResetInt(tenantsWithOutOfOrderEnabledStatName)
minOutOfOrderTimeWindowSecondsStat = usagestats.GetAndResetInt(minOutOfOrderTimeWindowSecondsStatName)
maxOutOfOrderTimeWindowSecondsStat = usagestats.GetAndResetInt(maxOutOfOrderTimeWindowSecondsStatName)
Expand Down Expand Up @@ -839,6 +841,7 @@ func (i *Ingester) updateActiveSeries(now time.Time) {
func (i *Ingester) updateUsageStats() {
memoryUsersCount := int64(0)
memorySeriesCount := int64(0)
activeSeriesCount := int64(0)
tenantsWithOutOfOrderEnabledCount := int64(0)
minOutOfOrderTimeWindow := time.Duration(0)
maxOutOfOrderTimeWindow := time.Duration(0)
Expand All @@ -858,6 +861,9 @@ func (i *Ingester) updateUsageStats() {
memoryUsersCount++
memorySeriesCount += int64(numSeries)

activeSeries, _, _ := userDB.activeSeries.Active()
activeSeriesCount += int64(activeSeries)

oooWindow := i.limits.OutOfOrderTimeWindow(userID)
if oooWindow > 0 {
tenantsWithOutOfOrderEnabledCount++
Expand All @@ -873,6 +879,7 @@ func (i *Ingester) updateUsageStats() {

// Track anonymous usage stats.
memorySeriesStats.Set(memorySeriesCount)
activeSeriesStats.Set(activeSeriesCount)
memoryTenantsStats.Set(memoryUsersCount)
tenantsWithOutOfOrderEnabledStat.Set(tenantsWithOutOfOrderEnabledCount)
minOutOfOrderTimeWindowSecondsStat.Set(int64(minOutOfOrderTimeWindow.Seconds()))
Expand Down
3 changes: 3 additions & 0 deletions pkg/ingester/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2794,6 +2794,9 @@ func TestIngester_Push(t *testing.T) {

i.updateUsageStats()

if !testData.disableActiveSeries {
assert.Equal(t, int64(len(testData.expectedIngested)), usagestats.GetInt(activeSeriesStatsName).Value())
}
assert.Equal(t, int64(len(testData.expectedIngested)), usagestats.GetInt(memorySeriesStatsName).Value())
assert.Equal(t, int64(expectedTenantsCount), usagestats.GetInt(memoryTenantsStatsName).Value())
assert.Equal(t, int64(expectedSamplesCount)+appendedSamplesStatsBefore, usagestats.GetCounter(appendedSamplesStatsName).Total())
Expand Down

0 comments on commit 2ec3b86

Please sign in to comment.