Expose prometheus_tsdb_lowest_timestamp metric (#363)
* Expose prometheus_tsdb_start_time_seconds metric Signed-off-by: Bob Shannon <bshannon@palantir.com> * Search for block with smallest minTime Signed-off-by: Bob Shannon <bshannon@palantir.com> * PR comments Signed-off-by: Bob Shannon <bshannon@palantir.com> * PR comment: Make metric name more accurate Signed-off-by: Bob Shannon <bshannon@palantir.com>
This commit is contained in:
parent
9be883670e
commit
cb7f320d42
13
db.go
13
db.go
|
@ -125,6 +125,7 @@ type dbMetrics struct {
|
||||||
compactionsTriggered prometheus.Counter
|
compactionsTriggered prometheus.Counter
|
||||||
cutoffs prometheus.Counter
|
cutoffs prometheus.Counter
|
||||||
cutoffsFailed prometheus.Counter
|
cutoffsFailed prometheus.Counter
|
||||||
|
startTime prometheus.GaugeFunc
|
||||||
tombCleanTimer prometheus.Histogram
|
tombCleanTimer prometheus.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +173,17 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
|
||||||
Name: "prometheus_tsdb_retention_cutoffs_failures_total",
|
Name: "prometheus_tsdb_retention_cutoffs_failures_total",
|
||||||
Help: "Number of times the database failed to cut off block data from disk.",
|
Help: "Number of times the database failed to cut off block data from disk.",
|
||||||
})
|
})
|
||||||
|
m.startTime = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
|
||||||
|
Name: "prometheus_tsdb_lowest_timestamp",
|
||||||
|
Help: "Lowest timestamp value stored in the database.",
|
||||||
|
}, func() float64 {
|
||||||
|
db.mtx.RLock()
|
||||||
|
defer db.mtx.RUnlock()
|
||||||
|
if len(db.blocks) == 0 {
|
||||||
|
return float64(db.head.minTime)
|
||||||
|
}
|
||||||
|
return float64(db.blocks[0].meta.MinTime)
|
||||||
|
})
|
||||||
m.tombCleanTimer = prometheus.NewHistogram(prometheus.HistogramOpts{
|
m.tombCleanTimer = prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||||
Name: "prometheus_tsdb_tombstone_cleanup_seconds",
|
Name: "prometheus_tsdb_tombstone_cleanup_seconds",
|
||||||
Help: "The time taken to recompact blocks to remove tombstones.",
|
Help: "The time taken to recompact blocks to remove tombstones.",
|
||||||
|
@ -186,6 +198,7 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
|
||||||
m.cutoffs,
|
m.cutoffs,
|
||||||
m.cutoffsFailed,
|
m.cutoffsFailed,
|
||||||
m.compactionsTriggered,
|
m.compactionsTriggered,
|
||||||
|
m.startTime,
|
||||||
m.tombCleanTimer,
|
m.tombCleanTimer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue