|
|
|
|
@ -248,6 +248,7 @@ type dbMetrics struct { |
|
|
|
|
tombCleanTimer prometheus.Histogram |
|
|
|
|
blocksBytes prometheus.Gauge |
|
|
|
|
maxBytes prometheus.Gauge |
|
|
|
|
retentionDuration prometheus.Gauge |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics { |
|
|
|
|
@ -321,6 +322,10 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics { |
|
|
|
|
Name: "prometheus_tsdb_retention_limit_bytes", |
|
|
|
|
Help: "Max number of bytes to be retained in the tsdb blocks, configured 0 means disabled", |
|
|
|
|
}) |
|
|
|
|
m.retentionDuration = prometheus.NewGauge(prometheus.GaugeOpts{ |
|
|
|
|
Name: "prometheus_tsdb_retention_limit_seconds", |
|
|
|
|
Help: "How long to retain samples in storage.", |
|
|
|
|
}) |
|
|
|
|
m.sizeRetentionCount = prometheus.NewCounter(prometheus.CounterOpts{ |
|
|
|
|
Name: "prometheus_tsdb_size_retentions_total", |
|
|
|
|
Help: "The number of times that blocks were deleted because the maximum number of bytes was exceeded.", |
|
|
|
|
@ -341,6 +346,7 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics { |
|
|
|
|
m.tombCleanTimer, |
|
|
|
|
m.blocksBytes, |
|
|
|
|
m.maxBytes, |
|
|
|
|
m.retentionDuration, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
return m |
|
|
|
|
@ -877,6 +883,7 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs |
|
|
|
|
maxBytes = 0 |
|
|
|
|
} |
|
|
|
|
db.metrics.maxBytes.Set(float64(maxBytes)) |
|
|
|
|
db.metrics.retentionDuration.Set((time.Duration(opts.RetentionDuration) * time.Millisecond).Seconds()) |
|
|
|
|
|
|
|
|
|
if err := db.reload(); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
|