Add backupValidationFailureTotal to metrics (#2714)

* Add backValidationFailureTotal to metrics

Signed-off-by: Kathrin Mao <kathrin.mao@sap.com>
This commit is contained in:
kathpeony
2020-07-16 19:13:17 +02:00
committed by GitHub
parent a368370bef
commit 243ac62e3f
3 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1 @@
Add backupValidationFailureTotal to metrics

View File

@@ -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")

View File

@@ -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 {