Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a metric in compactor to record timestamp of last successful run #2788

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pkg/storage/stores/shipper/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (c *Compactor) Run(ctx context.Context) error {
c.metrics.compactTablesOperationTotal.WithLabelValues(status).Inc()
if status == statusSuccess {
c.metrics.compactTablesOperationDurationSeconds.Set(time.Since(start).Seconds())
c.metrics.compactTablesOperationLastSuccess.SetToCurrentTime()
}
}()

Expand Down
6 changes: 6 additions & 0 deletions pkg/storage/stores/shipper/compactor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
type metrics struct {
compactTablesOperationTotal *prometheus.CounterVec
compactTablesOperationDurationSeconds prometheus.Gauge
compactTablesOperationLastSuccess prometheus.Gauge
}

func newMetrics(r prometheus.Registerer) *metrics {
Expand All @@ -27,6 +28,11 @@ func newMetrics(r prometheus.Registerer) *metrics {
Name: "compact_tables_operation_duration_seconds",
Help: "Time (in seconds) spent in compacting all the tables",
}),
compactTablesOperationLastSuccess: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: "loki_boltdb_shipper",
Name: "compact_tables_operation_last_successful_run_timestamp_seconds",
Help: "Unix timestamp of the last successful compaction run",
}),
}

return &m
Expand Down