Add new gauge to hold the timestamp of the last successful backup (#1448)
* add new gauge to hold the timestamp of the last sucessfull backup Signed-off-by: fabito <fuechi@ciandt.com> * add changelog entry Signed-off-by: fabito <fuechi@ciandt.com> * fix gauge name Signed-off-by: fabito <fuechi@ciandt.com> * renaming metric to backup_last_successful_timestamp Signed-off-by: fabito <fuechi@ciandt.com> * fix typo Signed-off-by: fabito <fuechi@ciandt.com> * ✏️ fix typo II Signed-off-by: fabito <fuechi@ciandt.com> * 🔀 rename method Signed-off-by: fabito <fuechi@ciandt.com>pull/1461/head
parent
05b8edf894
commit
58d34700da
|
@ -0,0 +1 @@
|
|||
Expose the timestamp of the last successful backup in a gauge
|
|
@ -28,26 +28,27 @@ type ServerMetrics struct {
|
|||
}
|
||||
|
||||
const (
|
||||
metricNamespace = "velero"
|
||||
backupTarballSizeBytesGauge = "backup_tarball_size_bytes"
|
||||
backupTotal = "backup_total"
|
||||
backupAttemptTotal = "backup_attempt_total"
|
||||
backupSuccessTotal = "backup_success_total"
|
||||
backupPartialFailureTotal = "backup_partial_failure_total"
|
||||
backupFailureTotal = "backup_failure_total"
|
||||
backupDurationSeconds = "backup_duration_seconds"
|
||||
backupDeletionAttemptTotal = "backup_deletion_attempt_total"
|
||||
backupDeletionSuccessTotal = "backup_deletion_success_total"
|
||||
backupDeletionFailureTotal = "backup_deletion_failure_total"
|
||||
restoreTotal = "restore_total"
|
||||
restoreAttemptTotal = "restore_attempt_total"
|
||||
restoreValidationFailedTotal = "restore_validation_failed_total"
|
||||
restoreSuccessTotal = "restore_success_total"
|
||||
restorePartialFailureTotal = "restore_partial_failure_total"
|
||||
restoreFailedTotal = "restore_failed_total"
|
||||
volumeSnapshotAttemptTotal = "volume_snapshot_attempt_total"
|
||||
volumeSnapshotSuccessTotal = "volume_snapshot_success_total"
|
||||
volumeSnapshotFailureTotal = "volume_snapshot_failure_total"
|
||||
metricNamespace = "velero"
|
||||
backupTarballSizeBytesGauge = "backup_tarball_size_bytes"
|
||||
backupTotal = "backup_total"
|
||||
backupAttemptTotal = "backup_attempt_total"
|
||||
backupSuccessTotal = "backup_success_total"
|
||||
backupPartialFailureTotal = "backup_partial_failure_total"
|
||||
backupFailureTotal = "backup_failure_total"
|
||||
backupDurationSeconds = "backup_duration_seconds"
|
||||
backupDeletionAttemptTotal = "backup_deletion_attempt_total"
|
||||
backupDeletionSuccessTotal = "backup_deletion_success_total"
|
||||
backupDeletionFailureTotal = "backup_deletion_failure_total"
|
||||
backupLastSuccessfulTimestamp = "backup_last_successful_timestamp"
|
||||
restoreTotal = "restore_total"
|
||||
restoreAttemptTotal = "restore_attempt_total"
|
||||
restoreValidationFailedTotal = "restore_validation_failed_total"
|
||||
restoreSuccessTotal = "restore_success_total"
|
||||
restorePartialFailureTotal = "restore_partial_failure_total"
|
||||
restoreFailedTotal = "restore_failed_total"
|
||||
volumeSnapshotAttemptTotal = "volume_snapshot_attempt_total"
|
||||
volumeSnapshotSuccessTotal = "volume_snapshot_success_total"
|
||||
volumeSnapshotFailureTotal = "volume_snapshot_failure_total"
|
||||
|
||||
scheduleLabel = "schedule"
|
||||
backupNameLabel = "backupName"
|
||||
|
@ -67,6 +68,14 @@ func NewServerMetrics() *ServerMetrics {
|
|||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
backupLastSuccessfulTimestamp: prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: metricNamespace,
|
||||
Name: backupLastSuccessfulTimestamp,
|
||||
Help: "Last time a backup ran successfully, Unix timestamp in seconds",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
backupTotal: prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: metricNamespace,
|
||||
|
@ -287,6 +296,13 @@ func (m *ServerMetrics) SetBackupTarballSizeBytesGauge(backupSchedule string, si
|
|||
}
|
||||
}
|
||||
|
||||
// SetBackupLastSuccessfulTimestamp records the last time a backup ran successfully, Unix timestamp in seconds
|
||||
func (m *ServerMetrics) SetBackupLastSuccessfulTimestamp(backupSchedule string) {
|
||||
if g, ok := m.metrics[backupLastSuccessfulTimestamp].(*prometheus.GaugeVec); ok {
|
||||
g.WithLabelValues(backupSchedule).Set(float64(time.Now().Unix()))
|
||||
}
|
||||
}
|
||||
|
||||
// SetBackupTotal records the current number of existent backups.
|
||||
func (m *ServerMetrics) SetBackupTotal(numberOfBackups int64) {
|
||||
if g, ok := m.metrics[backupTotal].(prometheus.Gauge); ok {
|
||||
|
@ -306,6 +322,7 @@ func (m *ServerMetrics) RegisterBackupSuccess(backupSchedule string) {
|
|||
if c, ok := m.metrics[backupSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
m.SetBackupLastSuccessfulTimestamp(backupSchedule)
|
||||
}
|
||||
|
||||
// RegisterBackupPartialFailure records a partially failed backup.
|
||||
|
|
Loading…
Reference in New Issue