From 8a31fb55ef76714f617f079b67a573906f9cea77 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 4 Jan 2025 14:22:20 +0100 Subject: prometheus: Add silentct_need_restart --- internal/manager/manager.go | 1 + internal/metrics/metrics.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/manager/manager.go b/internal/manager/manager.go index e302b4f..90f6507 100644 --- a/internal/manager/manager.go +++ b/internal/manager/manager.go @@ -182,6 +182,7 @@ func (mgr *Manager) addLogs(ctx context.Context, logs []metadata.Log) { mgr.Logger.Infof("adding log %s with existing state on disk\n", log.URL) } else if err != nil { mgr.Logger.Noticef("restart required: failed to bootstrap new log %s: %v\n", log.URL, err) + mgr.Metrics.NeedRestart() } else { mgr.Logger.Infof("bootstrapping log %s at next index 0\n", log.URL) } diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 17e9cce..c5ff0d6 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -12,6 +12,7 @@ type Metrics struct { logTimestamp *prometheus.GaugeVec certificateAlert *prometheus.GaugeVec errorCounter prometheus.Counter + needRestart prometheus.Gauge } func NewMetrics(registry *prometheus.Registry) *Metrics { @@ -50,9 +51,15 @@ func NewMetrics(registry *prometheus.Registry) *Metrics { Help: "The number of errors propagated to the main loop.", }, ), + needRestart: prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "silentct_need_restart", + Help: "A non-zero value if the monitor needs restarting.", + }, + ), } - registry.MustRegister(m.logSize, m.logIndex, m.logTimestamp, m.certificateAlert, m.errorCounter) + registry.MustRegister(m.logSize, m.logIndex, m.logTimestamp, m.certificateAlert, m.errorCounter, m.needRestart) return m } @@ -80,3 +87,7 @@ func (m *Metrics) CertificateAlert(alerts []index.CertificateInfo) { func (m *Metrics) CountError() { m.errorCounter.Inc() } + +func (m *Metrics) NeedRestart() { + m.needRestart.Set(float64(1)) +} -- cgit v1.2.3