Skip to content

blockbuilder: set up per-tenant TSDB metrics#14364

Open
narqo wants to merge 2 commits intomainfrom
vldmr/block-builder-tsdb-metrics
Open

blockbuilder: set up per-tenant TSDB metrics#14364
narqo wants to merge 2 commits intomainfrom
vldmr/block-builder-tsdb-metrics

Conversation

@narqo
Copy link
Contributor

@narqo narqo commented Feb 13, 2026

What this PR does

Following #14363

This PR exposes per-tenant TSDB metrics from the block-builder.

narqo added a commit that referenced this pull request Feb 13, 2026
#### What this PR does

This PR moves the per-tenant `TSDBMetrics` collector out of the
`ingester` package to allow these metrics to be re-used in the
block-builder (I've moved the changes in the `blockbuilder` package are
to [a separate PR](#14364), to
simplify the review).

The changes here are aimed to be pure structural. I don't expect any
changes in the existing metrics — currently testing that in a dev
environment, and all relevant metrics look fine.

---------

Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
@narqo narqo force-pushed the vldmr/block-builder-tsdb-metrics branch from 9db16f1 to 7c840c7 Compare February 13, 2026 17:37
@narqo narqo marked this pull request as ready for review February 13, 2026 17:38
@narqo narqo requested a review from a team as a code owner February 13, 2026 17:38
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

@cursor
Copy link

cursor bot commented Feb 13, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Close() leaks per-tenant TSDB metric registries
    • Added per-tenant metric registry cleanup to Close() method, matching the cleanup logic already present in CompactAndUpload().

Create PR

Or push these changes by commenting:

@cursor push 8467778f39
Preview (8467778f39)
diff --git a/pkg/blockbuilder/tsdb.go b/pkg/blockbuilder/tsdb.go
--- a/pkg/blockbuilder/tsdb.go
+++ b/pkg/blockbuilder/tsdb.go
@@ -480,6 +480,11 @@
 		merr.Add(os.RemoveAll(dbDir))
 	}
 
+	// Remove all registered per-tenant TSDB metrics. Their local DBs are wiped out from the block-builder no-matter what.
+	for tenant := range b.tsdbs {
+		b.tsdbMetrics.RemoveRegistryForTenant(tenant.tenantID)
+	}
+
 	// Clear the map so that it can be released from the memory. Not setting to nil in case
 	// we want to reuse the TSDBBuilder.
 	b.tsdbs = make(map[tsdbTenant]*userTSDB)

Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
@narqo narqo force-pushed the vldmr/block-builder-tsdb-metrics branch from 7c840c7 to 4cec80d Compare February 13, 2026 18:55
Copy link
Contributor

@tacole02 tacole02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments