From 269d8069d84580d46ba547fbb43d4a0479dd04c6 Mon Sep 17 00:00:00 2001 From: allenxu404 Date: Tue, 20 Feb 2024 17:12:24 +0800 Subject: [PATCH] Adjust the logic for the backup_last_status metric to stop incorrectly incrementing over time Signed-off-by: allenxu404 --- changelogs/unreleased/7445-allenxu404 | 1 + pkg/metrics/metrics.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/7445-allenxu404 diff --git a/changelogs/unreleased/7445-allenxu404 b/changelogs/unreleased/7445-allenxu404 new file mode 100644 index 0000000000..a21901d472 --- /dev/null +++ b/changelogs/unreleased/7445-allenxu404 @@ -0,0 +1 @@ +Adjust the logic for the backup_last_status metric to stop incorrectly incrementing over time \ No newline at end of file diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index b1bcaf765a..61b91812d8 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -468,7 +468,7 @@ func (m *ServerMetrics) InitSchedule(scheduleName string) { c.WithLabelValues(scheduleName).Add(0) } if c, ok := m.metrics[backupLastStatus].(*prometheus.GaugeVec); ok { - c.WithLabelValues(scheduleName).Add(1) + c.WithLabelValues(scheduleName).Set(float64(1)) } if c, ok := m.metrics[restoreAttemptTotal].(*prometheus.CounterVec); ok { c.WithLabelValues(scheduleName).Add(0)