Skip to content

Commit

Permalink
add a metric in compactor to record timestamp of last successful run (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepsukhani authored Oct 22, 2020
1 parent 2e14c45 commit 7b7b184
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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

0 comments on commit 7b7b184

Please sign in to comment.