Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Expose prometheus_tsdb_start_time_seconds metric
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Shannon <bshannon@palantir.com>
  • Loading branch information
Bob Shannon committed Jul 14, 2018
1 parent 99a2c43 commit e8e00c6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type dbMetrics struct {
compactionsTriggered prometheus.Counter
cutoffs prometheus.Counter
cutoffsFailed prometheus.Counter
startTime prometheus.Gauge
tombCleanTimer prometheus.Histogram
}

Expand Down Expand Up @@ -157,6 +158,10 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
Name: "prometheus_tsdb_retention_cutoffs_failures_total",
Help: "Number of times the database failed to cut off block data from disk.",
})
m.startTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "prometheus_tsdb_start_time_seconds",
Help: "Oldest timestamp stored in the database.",
})
m.tombCleanTimer = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "prometheus_tsdb_tombstone_cleanup_seconds",
Help: "The time taken to recompact blocks to remove tombstones.",
Expand All @@ -170,6 +175,7 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
m.cutoffs,
m.cutoffsFailed,
m.compactionsTriggered,
m.startTime,
m.tombCleanTimer,
)
}
Expand Down Expand Up @@ -238,6 +244,9 @@ func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db

go db.run()

head := db.Head()
db.metrics.startTime.Set(float64(head.minTime))

return db, nil
}

Expand Down

0 comments on commit e8e00c6

Please sign in to comment.