@@ -157,6 +157,7 @@ type dbMetrics struct {
157157 startTime prometheus.GaugeFunc
158158 tombCleanTimer prometheus.Histogram
159159 blocksBytes prometheus.Gauge
160+ maxBytes prometheus.Gauge
160161 sizeRetentionCount prometheus.Counter
161162}
162163
@@ -227,6 +228,10 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
227228 Name : "prometheus_tsdb_storage_blocks_bytes" ,
228229 Help : "The number of bytes that are currently used for local storage by all blocks." ,
229230 })
231+ m .maxBytes = prometheus .NewGauge (prometheus.GaugeOpts {
232+ Name : "prometheus_tsdb_retention_limit_bytes" ,
233+ Help : "Max number of bytes to be retained in the tsdb blocks, configured 0 means disabled" ,
234+ })
230235 m .sizeRetentionCount = prometheus .NewCounter (prometheus.CounterOpts {
231236 Name : "prometheus_tsdb_size_retentions_total" ,
232237 Help : "The number of times that blocks were deleted because the maximum number of bytes was exceeded." ,
@@ -244,6 +249,7 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
244249 m .startTime ,
245250 m .tombCleanTimer ,
246251 m .blocksBytes ,
252+ m .maxBytes ,
247253 m .sizeRetentionCount ,
248254 )
249255 }
@@ -454,6 +460,12 @@ func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db
454460 }
455461 db .metrics = newDBMetrics (db , r )
456462
463+ maxBytes := opts .MaxBytes
464+ if maxBytes < 0 {
465+ maxBytes = 0
466+ }
467+ db .metrics .maxBytes .Set (float64 (maxBytes ))
468+
457469 if ! opts .NoLockfile {
458470 absdir , err := filepath .Abs (dir )
459471 if err != nil {
0 commit comments