mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 04:38:48 -08:00
Merge pull request #167 from simonpasquier/instrument-wal-corruptions
Instrument WAL corruptions
This commit is contained in:
commit
74b0336d06
7
wal.go
7
wal.go
|
@ -68,6 +68,7 @@ type DeletesCB func([]Stone) error
|
||||||
|
|
||||||
type walMetrics struct {
|
type walMetrics struct {
|
||||||
fsyncDuration prometheus.Summary
|
fsyncDuration prometheus.Summary
|
||||||
|
corruptions prometheus.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWalMetrics(wal *SegmentWAL, r prometheus.Registerer) *walMetrics {
|
func newWalMetrics(wal *SegmentWAL, r prometheus.Registerer) *walMetrics {
|
||||||
|
@ -77,10 +78,15 @@ func newWalMetrics(wal *SegmentWAL, r prometheus.Registerer) *walMetrics {
|
||||||
Name: "tsdb_wal_fsync_duration_seconds",
|
Name: "tsdb_wal_fsync_duration_seconds",
|
||||||
Help: "Duration of WAL fsync.",
|
Help: "Duration of WAL fsync.",
|
||||||
})
|
})
|
||||||
|
m.corruptions = prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Name: "tsdb_wal_corruptions_total",
|
||||||
|
Help: "Total number of WAL corruptions.",
|
||||||
|
})
|
||||||
|
|
||||||
if r != nil {
|
if r != nil {
|
||||||
r.MustRegister(
|
r.MustRegister(
|
||||||
m.fsyncDuration,
|
m.fsyncDuration,
|
||||||
|
m.corruptions,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
|
@ -247,6 +253,7 @@ func (r *repairingWALReader) Read(series SeriesCB, samples SamplesCB, deletes De
|
||||||
if !ok {
|
if !ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
r.wal.metrics.corruptions.Inc()
|
||||||
return r.wal.truncate(cerr.err, cerr.file, cerr.lastOffset)
|
return r.wal.truncate(cerr.err, cerr.file, cerr.lastOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue