mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-16 04:06:06 +00:00
@@ -49,27 +49,6 @@ const (
|
||||
backupNameLabel = "backupName"
|
||||
|
||||
secondsInMinute = 60.0
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
legacyMetricNamespace = "ark"
|
||||
|
||||
// These variables are used only as the keys into a map; the standard variable names above are what is rendered for Prometheus
|
||||
// The Prometheus metric types themselves will take a namespace (ark or velero) and the metric name to construct the output that is scraped.
|
||||
legacyBackupTarballSizeBytesGauge = "ark-backup_tarball_size_bytes"
|
||||
legacyBackupAttemptTotal = "ark-backup_attempt_total"
|
||||
legacyBackupSuccessTotal = "ark-backup_success_total"
|
||||
legacyBackupFailureTotal = "ark-backup_failure_total"
|
||||
legacyBackupDurationSeconds = "ark-backup_duration_seconds"
|
||||
legacyRestoreAttemptTotal = "ark-restore_attempt_total"
|
||||
legacyRestoreValidationFailedTotal = "ark-restore_validation_failed_total"
|
||||
legacyRestoreSuccessTotal = "ark-restore_success_total"
|
||||
legacyRestoreFailedTotal = "ark-restore_failed_total"
|
||||
legacyVolumeSnapshotAttemptTotal = "ark-volume_snapshot_attempt_total"
|
||||
legacyVolumeSnapshotSuccessTotal = "ark-volume_snapshot_success_total"
|
||||
legacyVolumeSnapshotFailureTotal = "ark-volume_snapshot_failure_total"
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
)
|
||||
|
||||
// NewServerMetrics returns new ServerMetrics
|
||||
@@ -207,118 +186,6 @@ func NewServerMetrics() *ServerMetrics {
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
// -------------------------------------------------------------------
|
||||
// Ark backwards compatibility code
|
||||
// TODO: remove this code to drop the ark-namespaced metrics.
|
||||
legacyBackupTarballSizeBytesGauge: prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: backupTarballSizeBytesGauge,
|
||||
Help: "Size, in bytes, of a backup",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyBackupAttemptTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: backupAttemptTotal,
|
||||
Help: "Total number of attempted backups",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyBackupSuccessTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: backupSuccessTotal,
|
||||
Help: "Total number of successful backups",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyBackupFailureTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: backupFailureTotal,
|
||||
Help: "Total number of failed backups",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyBackupDurationSeconds: prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: backupDurationSeconds,
|
||||
Help: "Time taken to complete backup, in seconds",
|
||||
Buckets: []float64{
|
||||
toSeconds(1 * time.Minute),
|
||||
toSeconds(5 * time.Minute),
|
||||
toSeconds(10 * time.Minute),
|
||||
toSeconds(15 * time.Minute),
|
||||
toSeconds(30 * time.Minute),
|
||||
toSeconds(1 * time.Hour),
|
||||
toSeconds(2 * time.Hour),
|
||||
toSeconds(3 * time.Hour),
|
||||
toSeconds(4 * time.Hour),
|
||||
},
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyRestoreAttemptTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: restoreAttemptTotal,
|
||||
Help: "Total number of attempted restores",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyRestoreSuccessTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: restoreSuccessTotal,
|
||||
Help: "Total number of successful restores",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyRestoreFailedTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: restoreFailedTotal,
|
||||
Help: "Total number of failed restores",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyRestoreValidationFailedTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: restoreValidationFailedTotal,
|
||||
Help: "Total number of failed restores failing validations",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyVolumeSnapshotAttemptTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: volumeSnapshotAttemptTotal,
|
||||
Help: "Total number of attempted volume snapshots",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyVolumeSnapshotSuccessTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: volumeSnapshotSuccessTotal,
|
||||
Help: "Total number of successful volume snapshots",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
legacyVolumeSnapshotFailureTotal: prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: legacyMetricNamespace,
|
||||
Name: volumeSnapshotFailureTotal,
|
||||
Help: "Total number of failed volume snapshots",
|
||||
},
|
||||
[]string{scheduleLabel},
|
||||
),
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -371,41 +238,6 @@ func (m *ServerMetrics) InitSchedule(scheduleName string) {
|
||||
if c, ok := m.metrics[volumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyBackupAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyBackupSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyBackupFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyRestoreAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyRestoreFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyRestoreSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyRestoreValidationFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(scheduleName).Set(0)
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// SetBackupTarballSizeBytesGauge records the size, in bytes, of a backup tarball.
|
||||
@@ -413,13 +245,6 @@ func (m *ServerMetrics) SetBackupTarballSizeBytesGauge(backupSchedule string, si
|
||||
if g, ok := m.metrics[backupTarballSizeBytesGauge].(*prometheus.GaugeVec); ok {
|
||||
g.WithLabelValues(backupSchedule).Set(float64(size))
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if g, ok := m.metrics[legacyBackupTarballSizeBytesGauge].(*prometheus.GaugeVec); ok {
|
||||
g.WithLabelValues(backupSchedule).Set(float64(size))
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterBackupAttempt records an backup attempt.
|
||||
@@ -427,13 +252,6 @@ func (m *ServerMetrics) RegisterBackupAttempt(backupSchedule string) {
|
||||
if c, ok := m.metrics[backupAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyBackupAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterBackupSuccess records a successful completion of a backup.
|
||||
@@ -441,13 +259,6 @@ func (m *ServerMetrics) RegisterBackupSuccess(backupSchedule string) {
|
||||
if c, ok := m.metrics[backupSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyBackupSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterBackupFailed records a failed backup.
|
||||
@@ -455,13 +266,6 @@ func (m *ServerMetrics) RegisterBackupFailed(backupSchedule string) {
|
||||
if c, ok := m.metrics[backupFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyBackupFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterBackupDuration records the number of seconds a backup took.
|
||||
@@ -469,13 +273,6 @@ func (m *ServerMetrics) RegisterBackupDuration(backupSchedule string, seconds fl
|
||||
if c, ok := m.metrics[backupDurationSeconds].(*prometheus.HistogramVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Observe(seconds)
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyBackupDurationSeconds].(*prometheus.HistogramVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Observe(seconds)
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterBackupDeletionAttempt records the number of attempted backup deletions
|
||||
@@ -510,13 +307,6 @@ func (m *ServerMetrics) RegisterRestoreAttempt(backupSchedule string) {
|
||||
if c, ok := m.metrics[restoreAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyRestoreAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterRestoreSuccess records a successful (maybe partial) completion of a restore.
|
||||
@@ -524,13 +314,6 @@ func (m *ServerMetrics) RegisterRestoreSuccess(backupSchedule string) {
|
||||
if c, ok := m.metrics[restoreSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyRestoreSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterRestoreFailed records a restore that failed.
|
||||
@@ -538,13 +321,6 @@ func (m *ServerMetrics) RegisterRestoreFailed(backupSchedule string) {
|
||||
if c, ok := m.metrics[restoreFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyRestoreFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterRestoreValidationFailed records a restore that failed validation.
|
||||
@@ -552,13 +328,6 @@ func (m *ServerMetrics) RegisterRestoreValidationFailed(backupSchedule string) {
|
||||
if c, ok := m.metrics[restoreValidationFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyRestoreValidationFailedTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Inc()
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterVolumeSnapshotAttempts records an attempt to snapshot a volume.
|
||||
@@ -566,13 +335,6 @@ func (m *ServerMetrics) RegisterVolumeSnapshotAttempts(backupSchedule string, vo
|
||||
if c, ok := m.metrics[volumeSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsAttempted))
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsAttempted))
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterVolumeSnapshotSuccesses records a completed volume snapshot.
|
||||
@@ -580,13 +342,6 @@ func (m *ServerMetrics) RegisterVolumeSnapshotSuccesses(backupSchedule string, v
|
||||
if c, ok := m.metrics[volumeSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsCompleted))
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsCompleted))
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// RegisterVolumeSnapshotFailures records a failed volume snapshot.
|
||||
@@ -594,11 +349,4 @@ func (m *ServerMetrics) RegisterVolumeSnapshotFailures(backupSchedule string, vo
|
||||
if c, ok := m.metrics[volumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsFailed))
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
// TODO: remove this code to remove the ark-namespaced metrics
|
||||
if c, ok := m.metrics[legacyVolumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
||||
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsFailed))
|
||||
}
|
||||
// TODO: remove code above this comment
|
||||
// -------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user