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

Commit 59ebdbd

Browse files
brian-brazilgouthamve
authored andcommitted
Add metrics for isolation.
1 parent efd5bf1 commit 59ebdbd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

db.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ type DB struct {
131131

132132
type dbMetrics struct {
133133
loadedBlocks prometheus.GaugeFunc
134+
lowWatermark prometheus.GaugeFunc
135+
highWatermark prometheus.GaugeFunc
134136
reloads prometheus.Counter
135137
reloadsFailed prometheus.Counter
136138
compactionsTriggered prometheus.Counter
@@ -150,6 +152,20 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
150152
defer db.mtx.RUnlock()
151153
return float64(len(db.blocks))
152154
})
155+
m.lowWatermark = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
156+
Name: "tsdb_isolation_low_watermark",
157+
Help: "The lowest write id that is still referenced.",
158+
}, func() float64 {
159+
return float64(db.readLowWatermark())
160+
})
161+
m.highWatermark = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
162+
Name: "tsdb_isolation_high_watermark",
163+
Help: "The highest write id that has been given out.",
164+
}, func() float64 {
165+
db.writeMtx.Lock()
166+
defer db.writeMtx.Unlock()
167+
return float64(db.writeLastId)
168+
})
153169
m.reloads = prometheus.NewCounter(prometheus.CounterOpts{
154170
Name: "prometheus_tsdb_reloads_total",
155171
Help: "Number of times the database reloaded block data from disk.",
@@ -178,6 +194,8 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
178194
if r != nil {
179195
r.MustRegister(
180196
m.loadedBlocks,
197+
m.lowWatermark,
198+
m.highWatermark,
181199
m.reloads,
182200
m.reloadsFailed,
183201
m.cutoffs,

0 commit comments

Comments
 (0)