From 67fda81cecc8e4f108286b859ecfae2b3d2bd5f1 Mon Sep 17 00:00:00 2001 From: Goutham Annem Date: Sun, 5 Jul 2026 10:04:16 -0700 Subject: [PATCH] fix(compactor): correct misleading help text for cortex_compactor_garbage_collected_blocks_total The metric counted blocks garbage collected by the Thanos syncer (i.e., blocks deleted after being marked), not all blocks marked for deletion. Its help string was identical to cortex_compactor_blocks_marked_for_deletion_total, which caused confusion for operators monitoring compaction activity. Fixes #3610 Signed-off-by: Goutham Annem --- CHANGELOG.md | 1 + pkg/compactor/compactor_metrics.go | 2 +- pkg/compactor/compactor_metrics_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e35a4f42ab1..f386b5c32e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ * [ENHANCEMENT] Compactor: Reduce object storage GET calls when updating the bucket index by skipping re-reading parquet converter markers for blocks that already have a valid-version parquet entry in the previous index. #7669 * [ENHANCEMENT] Upgrade Thanos and promql-engine to latest. #7740 * [ENHANCEMENT] Ruler: Adjust ruler frontend decoder to not wrap query error messages with execution prefix, this makes error responses consistent between internal and external ruler paths. #7741 +* [BUGFIX] Compactor: Correct misleading help text for `cortex_compactor_garbage_collected_blocks_total` metric; it counted blocks garbage collected by the syncer, not all blocks marked for deletion. #3610 * [BUGFIX] Querier: Fix queryWithRetry and labelsWithRetry returning (nil, nil) on cancelled context by propagating ctx.Err(). #7370 * [BUGFIX] Metrics Helper: Fix non-deterministic bucket order in merged histograms by sorting buckets after map iteration, matching Prometheus client library behavior. #7380 * [BUGFIX] Distributor: Return HTTP 401 Unauthorized when tenant ID resolution fails in the Prometheus Remote Write 2.0 path. #7389 diff --git a/pkg/compactor/compactor_metrics.go b/pkg/compactor/compactor_metrics.go index d777ca9e8e7..d1dbd3e9cdd 100644 --- a/pkg/compactor/compactor_metrics.go +++ b/pkg/compactor/compactor_metrics.go @@ -120,7 +120,7 @@ func newCompactorMetricsWithLabels(reg prometheus.Registerer, commonLabels []str // Copied from Thanos, pkg/compact/compact.go. m.syncerGarbageCollectedBlocks = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ Name: "cortex_compactor_garbage_collected_blocks_total", - Help: "Total number of blocks marked for deletion by compactor.", + Help: "Total number of blocks garbage collected (deleted after being marked) by the compactor syncer.", }, nil) m.syncerGarbageCollections = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ Name: "cortex_compactor_garbage_collection_total", diff --git a/pkg/compactor/compactor_metrics_test.go b/pkg/compactor/compactor_metrics_test.go index 0288bbe909f..b1c4e415724 100644 --- a/pkg/compactor/compactor_metrics_test.go +++ b/pkg/compactor/compactor_metrics_test.go @@ -65,7 +65,7 @@ func TestCompactorMetrics(t *testing.T) { cortex_compactor_blocks_marked_for_deletion_total{reason="compaction",user="aaa"} 144430 cortex_compactor_blocks_marked_for_deletion_total{reason="compaction",user="bbb"} 155540 cortex_compactor_blocks_marked_for_deletion_total{reason="compaction",user="ccc"} 166650 - # HELP cortex_compactor_garbage_collected_blocks_total Total number of blocks marked for deletion by compactor. + # HELP cortex_compactor_garbage_collected_blocks_total Total number of blocks garbage collected (deleted after being marked) by the compactor syncer. # TYPE cortex_compactor_garbage_collected_blocks_total counter cortex_compactor_garbage_collected_blocks_total 99990 # HELP cortex_compactor_garbage_collection_duration_seconds Time it took to perform garbage collection iteration.