Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ type compactMetrics struct {
blockCleanupFailures prometheus.Counter
blocksMarked *prometheus.CounterVec
garbageCollectedBlocks prometheus.Counter
tenantIterations *prometheus.CounterVec
tenantAssigned *prometheus.GaugeVec
}

func newCompactMetrics(reg *prometheus.Registry, deleteDelay time.Duration) *compactMetrics {
Expand Down Expand Up @@ -185,6 +187,14 @@ func newCompactMetrics(reg *prometheus.Registry, deleteDelay time.Duration) *com
Name: "thanos_compact_garbage_collected_blocks_total",
Help: "Total number of blocks marked for deletion by compactor.",
})
m.tenantIterations = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_compact_tenant_iterations_total",
Help: "Total number of compaction iterations completed successfully per tenant.",
}, []string{"tenant"})
m.tenantAssigned = promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Name: "thanos_compact_tenant_assigned",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we also have this metric thanos_blocks_meta_assigned for tenant view (which tenant got assigned to which compactor` could we reuse that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

blocks_meta is more like "how many blocks seen per tenant" whereas tenant_iterations is "how many times has compaction run per tenant." I think this will be valuable for ensuring liveness and being able to alert on compaction stalls.

tenant_assigned is useful to check on startup but in steady-state it is redundant with the other two. Let me know if you think it's worth keeping

Help: "Set to 1 for each tenant assigned to this compactor instance.",
}, []string{"tenant"})
return m
}

Expand Down Expand Up @@ -294,6 +304,7 @@ func runCompact(
runWebServer(g, ctx, logger, cancel, reg, &conf, component, tracer, progressRegistry, globalBaseMetaFetcher, api, srv)

for _, tenantPrefix := range tenantPrefixes {
compactMetrics.tenantAssigned.WithLabelValues(tenantPrefix).Set(1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: remind me what is tenantPrefixes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it was v1/raw/<tenant> but now it's just <tenant>

bucketConf := &client.BucketConfig{
Type: initialBucketConf.Type,
Config: initialBucketConf.Config,
Expand Down Expand Up @@ -628,6 +639,7 @@ func runCompactForTenant(
err := compactMainFn(progressRegistry.Get(compact.Main))
if err == nil {
compactMetrics.iterations.Inc()
compactMetrics.tenantIterations.WithLabelValues(tenant).Inc()
return nil
}

Expand Down