mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Merge pull request #252 from simonpasquier/add-cuttoff-metrics
Count the total & failed numbers of block cutoffs
This commit is contained in:
commit
5b26bd5f6f
24
db.go
24
db.go
|
@ -122,6 +122,8 @@ type dbMetrics struct {
|
||||||
reloads prometheus.Counter
|
reloads prometheus.Counter
|
||||||
reloadsFailed prometheus.Counter
|
reloadsFailed prometheus.Counter
|
||||||
compactionsTriggered prometheus.Counter
|
compactionsTriggered prometheus.Counter
|
||||||
|
cutoffs prometheus.Counter
|
||||||
|
cutoffsFailed prometheus.Counter
|
||||||
tombCleanTimer prometheus.Histogram
|
tombCleanTimer prometheus.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +150,14 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
|
||||||
Name: "prometheus_tsdb_compactions_triggered_total",
|
Name: "prometheus_tsdb_compactions_triggered_total",
|
||||||
Help: "Total number of triggered compactions for the partition.",
|
Help: "Total number of triggered compactions for the partition.",
|
||||||
})
|
})
|
||||||
|
m.cutoffs = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Name: "prometheus_tsdb_retention_cutoffs_total",
|
||||||
|
Help: "Number of times the database cut off block data from disk.",
|
||||||
|
})
|
||||||
|
m.cutoffsFailed = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Name: "prometheus_tsdb_retention_cutoffs_failures_total",
|
||||||
|
Help: "Number of times the database failed to cut off block data from disk.",
|
||||||
|
})
|
||||||
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.",
|
||||||
|
@ -158,6 +168,8 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
|
||||||
m.loadedBlocks,
|
m.loadedBlocks,
|
||||||
m.reloads,
|
m.reloads,
|
||||||
m.reloadsFailed,
|
m.reloadsFailed,
|
||||||
|
m.cutoffs,
|
||||||
|
m.cutoffsFailed,
|
||||||
m.compactionsTriggered,
|
m.compactionsTriggered,
|
||||||
m.tombCleanTimer,
|
m.tombCleanTimer,
|
||||||
)
|
)
|
||||||
|
@ -277,7 +289,17 @@ func (db *DB) run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) retentionCutoff() (bool, error) {
|
func (db *DB) retentionCutoff() (b bool, err error) {
|
||||||
|
defer func() {
|
||||||
|
if !b && err == nil {
|
||||||
|
// no data had to be cut off.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db.metrics.cutoffs.Inc()
|
||||||
|
if err != nil {
|
||||||
|
db.metrics.cutoffsFailed.Inc()
|
||||||
|
}
|
||||||
|
}()
|
||||||
if db.opts.RetentionDuration == 0 {
|
if db.opts.RetentionDuration == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -800,7 +800,7 @@ func TestDB_Retention(t *testing.T) {
|
||||||
|
|
||||||
testutil.Equals(t, 2, len(db.blocks))
|
testutil.Equals(t, 2, len(db.blocks))
|
||||||
|
|
||||||
// Now call rentention.
|
// Now call retention.
|
||||||
changes, err := db.retentionCutoff()
|
changes, err := db.retentionCutoff()
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
testutil.Assert(t, changes, "there should be changes")
|
testutil.Assert(t, changes, "there should be changes")
|
||||||
|
|
Loading…
Reference in a new issue