@@ -45,18 +45,18 @@ type BlocksCleaner struct {
45
45
lastOwnedUsers []string
46
46
47
47
// Metrics.
48
- runsStarted prometheus.Counter
49
- runsCompleted prometheus.Counter
50
- runsFailed prometheus.Counter
51
- runsLastSuccess prometheus.Gauge
52
- blocksCleanedTotal prometheus.Counter
53
- blocksFailedTotal prometheus.Counter
54
- blocksMarkedForDeletion prometheus.Counter
55
- tenantBlocks * prometheus.GaugeVec
56
- tenantMarkedBlocks * prometheus.GaugeVec
57
- tenantPartialBlocks * prometheus.GaugeVec
58
- tenantBucketIndexLastUpdate * prometheus.GaugeVec
59
- tenantMarkedNoCompactBlocks * prometheus.GaugeVec
48
+ runsStarted prometheus.Counter
49
+ runsCompleted prometheus.Counter
50
+ runsFailed prometheus.Counter
51
+ runsLastSuccess prometheus.Gauge
52
+ blocksCleanedTotal prometheus.Counter
53
+ blocksFailedTotal prometheus.Counter
54
+ blocksMarkedForDeletion prometheus.Counter
55
+ tenantBlocks * prometheus.GaugeVec
56
+ tenantBlocksMarkedForDelete * prometheus.GaugeVec
57
+ tenantBlocksMarkedForNoCompaction * prometheus.GaugeVec
58
+ tenantPartialBlocks * prometheus.GaugeVec
59
+ tenantBucketIndexLastUpdate * prometheus.GaugeVec
60
60
}
61
61
62
62
func NewBlocksCleaner (cfg BlocksCleanerConfig , bucketClient objstore.Bucket , usersScanner * cortex_tsdb.UsersScanner , cfgProvider ConfigProvider , logger log.Logger , reg prometheus.Registerer ) * BlocksCleaner {
@@ -103,11 +103,11 @@ func NewBlocksCleaner(cfg BlocksCleanerConfig, bucketClient objstore.Bucket, use
103
103
Name : "cortex_bucket_blocks_count" ,
104
104
Help : "Total number of blocks in the bucket. Includes blocks marked for deletion, but not partial blocks." ,
105
105
}, []string {"user" }),
106
- tenantMarkedBlocks : promauto .With (reg ).NewGaugeVec (prometheus.GaugeOpts {
106
+ tenantBlocksMarkedForDelete : promauto .With (reg ).NewGaugeVec (prometheus.GaugeOpts {
107
107
Name : "cortex_bucket_blocks_marked_for_deletion_count" ,
108
108
Help : "Total number of blocks marked for deletion in the bucket." ,
109
109
}, []string {"user" }),
110
- tenantMarkedNoCompactBlocks : promauto .With (reg ).NewGaugeVec (prometheus.GaugeOpts {
110
+ tenantBlocksMarkedForNoCompaction : promauto .With (reg ).NewGaugeVec (prometheus.GaugeOpts {
111
111
Name : "cortex_bucket_blocks_marked_for_no_compaction_count" ,
112
112
Help : "Total number of blocks marked for no compaction in the bucket." ,
113
113
}, []string {"user" }),
@@ -173,8 +173,8 @@ func (c *BlocksCleaner) cleanUsers(ctx context.Context, firstRun bool) error {
173
173
for _ , userID := range c .lastOwnedUsers {
174
174
if ! isActive [userID ] && ! isDeleted [userID ] {
175
175
c .tenantBlocks .DeleteLabelValues (userID )
176
- c .tenantMarkedBlocks .DeleteLabelValues (userID )
177
- c .tenantMarkedNoCompactBlocks .DeleteLabelValues (userID )
176
+ c .tenantBlocksMarkedForDelete .DeleteLabelValues (userID )
177
+ c .tenantBlocksMarkedForNoCompaction .DeleteLabelValues (userID )
178
178
c .tenantPartialBlocks .DeleteLabelValues (userID )
179
179
c .tenantBucketIndexLastUpdate .DeleteLabelValues (userID )
180
180
}
@@ -237,16 +237,16 @@ func (c *BlocksCleaner) deleteUserMarkedForDeletion(ctx context.Context, userID
237
237
// to delete. We also consider them all marked for deletion given the next run will try
238
238
// to delete them again.
239
239
c .tenantBlocks .WithLabelValues (userID ).Set (float64 (failed ))
240
- c .tenantMarkedBlocks .WithLabelValues (userID ).Set (float64 (failed ))
240
+ c .tenantBlocksMarkedForDelete .WithLabelValues (userID ).Set (float64 (failed ))
241
241
c .tenantPartialBlocks .WithLabelValues (userID ).Set (0 )
242
242
243
243
return errors .Errorf ("failed to delete %d blocks" , failed )
244
244
}
245
245
246
246
// Given all blocks have been deleted, we can also remove the metrics.
247
247
c .tenantBlocks .DeleteLabelValues (userID )
248
- c .tenantMarkedBlocks .DeleteLabelValues (userID )
249
- c .tenantMarkedNoCompactBlocks .DeleteLabelValues (userID )
248
+ c .tenantBlocksMarkedForDelete .DeleteLabelValues (userID )
249
+ c .tenantBlocksMarkedForNoCompaction .DeleteLabelValues (userID )
250
250
c .tenantPartialBlocks .DeleteLabelValues (userID )
251
251
252
252
if deletedBlocks > 0 {
@@ -338,7 +338,6 @@ func (c *BlocksCleaner) cleanUser(ctx context.Context, userID string, firstRun b
338
338
// Generate an updated in-memory version of the bucket index.
339
339
w := bucketindex .NewUpdater (c .bucketClient , userID , c .cfgProvider , c .logger )
340
340
idx , partials , totalBlocksBlocksMarkedForNoCompaction , err := w .UpdateIndex (ctx , idx )
341
- c .tenantMarkedNoCompactBlocks .WithLabelValues (userID ).Set (float64 (totalBlocksBlocksMarkedForNoCompaction ))
342
341
if err != nil {
343
342
return err
344
343
}
@@ -375,7 +374,8 @@ func (c *BlocksCleaner) cleanUser(ctx context.Context, userID string, firstRun b
375
374
}
376
375
377
376
c .tenantBlocks .WithLabelValues (userID ).Set (float64 (len (idx .Blocks )))
378
- c .tenantMarkedBlocks .WithLabelValues (userID ).Set (float64 (len (idx .BlockDeletionMarks )))
377
+ c .tenantBlocksMarkedForDelete .WithLabelValues (userID ).Set (float64 (len (idx .BlockDeletionMarks )))
378
+ c .tenantBlocksMarkedForNoCompaction .WithLabelValues (userID ).Set (float64 (totalBlocksBlocksMarkedForNoCompaction ))
379
379
c .tenantBucketIndexLastUpdate .WithLabelValues (userID ).SetToCurrentTime ()
380
380
c .tenantPartialBlocks .WithLabelValues (userID ).Set (float64 (len (partials )))
381
381
0 commit comments