From 243ac62e3fea67659b74bf3bf4df520773895da3 Mon Sep 17 00:00:00 2001 From: kathpeony <68385123+kathpeony@users.noreply.github.com> Date: Thu, 16 Jul 2020 19:13:17 +0200 Subject: [PATCH] Add backupValidationFailureTotal to metrics (#2714) * Add backValidationFailureTotal to metrics Signed-off-by: Kathrin Mao --- changelogs/unreleased/2714-kathpeony | 1 + pkg/controller/backup_controller.go | 2 ++ pkg/metrics/metrics.go | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 changelogs/unreleased/2714-kathpeony diff --git a/changelogs/unreleased/2714-kathpeony b/changelogs/unreleased/2714-kathpeony new file mode 100644 index 000000000..89e261d9e --- /dev/null +++ b/changelogs/unreleased/2714-kathpeony @@ -0,0 +1 @@ +Add backupValidationFailureTotal to metrics diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index 366e81951..e958229ec 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -287,6 +287,8 @@ func (c *backupController) processBackup(key string) error { c.metrics.RegisterBackupPartialFailure(backupScheduleName) case velerov1api.BackupPhaseFailed: c.metrics.RegisterBackupFailed(backupScheduleName) + case velerov1api.BackupPhaseFailedValidation: + c.metrics.RegisterBackupValidationFailure(backupScheduleName) } log.Debug("Updating backup's final status") diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index d3ed0cbee..2e18c4345 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -35,6 +35,7 @@ const ( backupSuccessTotal = "backup_success_total" backupPartialFailureTotal = "backup_partial_failure_total" backupFailureTotal = "backup_failure_total" + backupValidationFailureTotal = "backup_validation_failure_total" backupDurationSeconds = "backup_duration_seconds" backupDeletionAttemptTotal = "backup_deletion_attempt_total" backupDeletionSuccessTotal = "backup_deletion_success_total" @@ -115,6 +116,14 @@ func NewServerMetrics() *ServerMetrics { }, []string{scheduleLabel}, ), + backupValidationFailureTotal: prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: metricNamespace, + Name: backupValidationFailureTotal, + Help: "Total number of validation failed backups", + }, + []string{scheduleLabel}, + ), backupDeletionAttemptTotal: prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: metricNamespace, @@ -254,6 +263,9 @@ func (m *ServerMetrics) InitSchedule(scheduleName string) { if c, ok := m.metrics[backupFailureTotal].(*prometheus.CounterVec); ok { c.WithLabelValues(scheduleName).Add(0) } + if c, ok := m.metrics[backupValidationFailureTotal].(*prometheus.CounterVec); ok { + c.WithLabelValues(scheduleName).Add(0) + } if c, ok := m.metrics[backupDeletionAttemptTotal].(*prometheus.CounterVec); ok { c.WithLabelValues(scheduleName).Add(0) } @@ -339,6 +351,13 @@ func (m *ServerMetrics) RegisterBackupFailed(backupSchedule string) { } } +// RegisterBackupValidationFailure records a validation failed backup. +func (m *ServerMetrics) RegisterBackupValidationFailure(backupSchedule string) { + if c, ok := m.metrics[backupValidationFailureTotal].(*prometheus.CounterVec); ok { + c.WithLabelValues(backupSchedule).Inc() + } +} + // RegisterBackupDuration records the number of seconds a backup took. func (m *ServerMetrics) RegisterBackupDuration(backupSchedule string, seconds float64) { if c, ok := m.metrics[backupDurationSeconds].(*prometheus.HistogramVec); ok {