Skip to content

Commit a8003f0

Browse files
thorfourThor
andauthored
tsdb: record a histogram of replay tsdb times (#2362)
Signed-off-by: Thor <thansen@digitalocean.com> Co-authored-by: Thor <thansen@digitalocean.com>
1 parent 83c6dce commit a8003f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/ingester/ingester_v2.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type TSDBState struct {
7575
// Head compactions metrics.
7676
compactionsTriggered prometheus.Counter
7777
compactionsFailed prometheus.Counter
78+
walReplayTime prometheus.Histogram
7879
}
7980

8081
// NewV2 returns a new Ingester that uses prometheus block storage instead of chunk storage
@@ -110,6 +111,11 @@ func NewV2(cfg Config, clientConfig client.Config, limits *validation.Overrides,
110111
Name: "cortex_ingester_tsdb_compactions_failed_total",
111112
Help: "Total number of compactions that failed.",
112113
}),
114+
walReplayTime: promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{
115+
Name: "cortex_ingester_tsdb_wal_replay_duration_seconds",
116+
Help: "The total time it takes to open and replay a TSDB WAL.",
117+
Buckets: prometheus.DefBuckets,
118+
}),
113119
},
114120
}
115121

@@ -857,6 +863,10 @@ func (i *Ingester) openExistingTSDB(ctx context.Context) error {
857863
go func(userID string) {
858864
defer wg.Done()
859865
defer openGate.Done()
866+
defer func(ts time.Time) {
867+
i.TSDBState.walReplayTime.Observe(time.Since(ts).Seconds())
868+
}(time.Now())
869+
860870
db, err := i.createTSDB(userID)
861871
if err != nil {
862872
level.Error(util.Logger).Log("msg", "unable to open user TSDB", "err", err, "user", userID)

0 commit comments

Comments
 (0)