From 94bb5c374154f1181d50fad9bd2b898d9ab33537 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 541cc6856e3..868e24b89f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ * [ENHANCEMENT] Ingester: Add `cortex_ingester_tsdb_head_max_timestamp` metric that re-exports the TSDB head max timestamp (`prometheus_tsdb_head_max_time`) per user, to help investigate ingestion issues like out-of-bounds (too old sample) errors. #7694 * [ENHANCEMENT] Ingester: Include the TSDB head max time in the `out of bounds` and `too old sample` error messages, so that users can see how far behind the accepted time range a rejected sample is. #7695 * [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 +* [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.