2018-06-06 21:35:06 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 the Heptio Ark contributors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2018-06-20 18:08:07 +00:00
|
|
|
"time"
|
|
|
|
|
2018-06-06 21:35:06 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
2019-01-25 03:33:07 +00:00
|
|
|
// ServerMetrics contains Prometheus metrics for the Velero server.
|
2018-06-06 21:35:06 +00:00
|
|
|
type ServerMetrics struct {
|
|
|
|
metrics map[string]prometheus.Collector
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2019-01-25 03:33:07 +00:00
|
|
|
metricNamespace = "velero"
|
2018-10-23 21:04:45 +00:00
|
|
|
backupTarballSizeBytesGauge = "backup_tarball_size_bytes"
|
|
|
|
backupAttemptTotal = "backup_attempt_total"
|
|
|
|
backupSuccessTotal = "backup_success_total"
|
|
|
|
backupFailureTotal = "backup_failure_total"
|
2018-06-25 18:15:46 +00:00
|
|
|
backupDurationSeconds = "backup_duration_seconds"
|
|
|
|
restoreAttemptTotal = "restore_attempt_total"
|
|
|
|
restoreValidationFailedTotal = "restore_validation_failed_total"
|
|
|
|
restoreSuccessTotal = "restore_success_total"
|
2018-07-05 20:49:47 +00:00
|
|
|
restoreFailedTotal = "restore_failed_total"
|
2018-10-23 21:04:45 +00:00
|
|
|
volumeSnapshotAttemptTotal = "volume_snapshot_attempt_total"
|
|
|
|
volumeSnapshotSuccessTotal = "volume_snapshot_success_total"
|
|
|
|
volumeSnapshotFailureTotal = "volume_snapshot_failure_total"
|
2018-06-25 18:15:46 +00:00
|
|
|
|
|
|
|
scheduleLabel = "schedule"
|
|
|
|
backupNameLabel = "backupName"
|
2018-06-20 18:08:07 +00:00
|
|
|
|
|
|
|
secondsInMinute = 60.0
|
2019-01-25 03:33:07 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewServerMetrics returns new ServerMetrics
|
|
|
|
func NewServerMetrics() *ServerMetrics {
|
|
|
|
return &ServerMetrics{
|
|
|
|
metrics: map[string]prometheus.Collector{
|
|
|
|
backupTarballSizeBytesGauge: prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: backupTarballSizeBytesGauge,
|
|
|
|
Help: "Size, in bytes, of a backup",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-10-23 21:04:45 +00:00
|
|
|
backupAttemptTotal: prometheus.NewCounterVec(
|
2018-06-06 21:35:06 +00:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
2018-10-23 21:04:45 +00:00
|
|
|
Name: backupAttemptTotal,
|
2018-06-06 21:35:06 +00:00
|
|
|
Help: "Total number of attempted backups",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-10-23 21:04:45 +00:00
|
|
|
backupSuccessTotal: prometheus.NewCounterVec(
|
2018-06-06 21:35:06 +00:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
2018-10-23 21:04:45 +00:00
|
|
|
Name: backupSuccessTotal,
|
2018-06-06 21:35:06 +00:00
|
|
|
Help: "Total number of successful backups",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-10-23 21:04:45 +00:00
|
|
|
backupFailureTotal: prometheus.NewCounterVec(
|
2018-06-06 21:35:06 +00:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
2018-10-23 21:04:45 +00:00
|
|
|
Name: backupFailureTotal,
|
2018-06-06 21:35:06 +00:00
|
|
|
Help: "Total number of failed backups",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-06-20 18:08:07 +00:00
|
|
|
backupDurationSeconds: prometheus.NewHistogramVec(
|
|
|
|
prometheus.HistogramOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
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},
|
|
|
|
),
|
2018-06-25 18:15:46 +00:00
|
|
|
restoreAttemptTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: restoreAttemptTotal,
|
|
|
|
Help: "Total number of attempted restores",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
|
|
|
restoreSuccessTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: restoreSuccessTotal,
|
|
|
|
Help: "Total number of successful restores",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-07-05 20:49:47 +00:00
|
|
|
restoreFailedTotal: prometheus.NewCounterVec(
|
2018-06-25 18:15:46 +00:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
2018-07-05 20:49:47 +00:00
|
|
|
Name: restoreFailedTotal,
|
|
|
|
Help: "Total number of failed restores",
|
2018-06-25 18:15:46 +00:00
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
|
|
|
restoreValidationFailedTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: restoreValidationFailedTotal,
|
2018-07-05 20:49:47 +00:00
|
|
|
Help: "Total number of failed restores failing validations",
|
2018-06-25 18:15:46 +00:00
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2018-10-23 21:04:45 +00:00
|
|
|
volumeSnapshotAttemptTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: volumeSnapshotAttemptTotal,
|
|
|
|
Help: "Total number of attempted volume snapshots",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
|
|
|
volumeSnapshotSuccessTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: volumeSnapshotSuccessTotal,
|
|
|
|
Help: "Total number of successful volume snapshots",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
|
|
|
volumeSnapshotFailureTotal: prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: metricNamespace,
|
|
|
|
Name: volumeSnapshotFailureTotal,
|
|
|
|
Help: "Total number of failed volume snapshots",
|
|
|
|
},
|
|
|
|
[]string{scheduleLabel},
|
|
|
|
),
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 18:08:07 +00:00
|
|
|
// RegisterAllMetrics registers all prometheus metrics.
|
2018-06-06 21:35:06 +00:00
|
|
|
func (m *ServerMetrics) RegisterAllMetrics() {
|
|
|
|
for _, pm := range m.metrics {
|
|
|
|
prometheus.MustRegister(pm)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 21:04:45 +00:00
|
|
|
// InitSchedule initializes counter metrics of a schedule.
|
2018-07-20 13:03:44 +00:00
|
|
|
func (m *ServerMetrics) InitSchedule(scheduleName string) {
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupAttemptTotal].(*prometheus.CounterVec); ok {
|
2018-07-20 13:03:44 +00:00
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupSuccessTotal].(*prometheus.CounterVec); ok {
|
2018-07-20 13:03:44 +00:00
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupFailureTotal].(*prometheus.CounterVec); ok {
|
2018-07-20 13:03:44 +00:00
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
2018-07-05 20:49:47 +00:00
|
|
|
if c, ok := m.metrics[restoreAttemptTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
|
|
|
if c, ok := m.metrics[restoreFailedTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
|
|
|
if c, ok := m.metrics[restoreSuccessTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
|
|
|
if c, ok := m.metrics[restoreValidationFailedTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[volumeSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
|
|
|
if c, ok := m.metrics[volumeSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
|
|
|
if c, ok := m.metrics[volumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(scheduleName).Set(0)
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-07-20 13:03:44 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 18:08:07 +00:00
|
|
|
// SetBackupTarballSizeBytesGauge records the size, in bytes, of a backup tarball.
|
2018-06-06 21:35:06 +00:00
|
|
|
func (m *ServerMetrics) SetBackupTarballSizeBytesGauge(backupSchedule string, size int64) {
|
|
|
|
if g, ok := m.metrics[backupTarballSizeBytesGauge].(*prometheus.GaugeVec); ok {
|
|
|
|
g.WithLabelValues(backupSchedule).Set(float64(size))
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 18:08:07 +00:00
|
|
|
// RegisterBackupAttempt records an backup attempt.
|
2018-06-06 21:35:06 +00:00
|
|
|
func (m *ServerMetrics) RegisterBackupAttempt(backupSchedule string) {
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupAttemptTotal].(*prometheus.CounterVec); ok {
|
2018-06-06 21:35:06 +00:00
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 18:08:07 +00:00
|
|
|
// RegisterBackupSuccess records a successful completion of a backup.
|
2018-06-06 21:35:06 +00:00
|
|
|
func (m *ServerMetrics) RegisterBackupSuccess(backupSchedule string) {
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupSuccessTotal].(*prometheus.CounterVec); ok {
|
2018-06-06 21:35:06 +00:00
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 18:08:07 +00:00
|
|
|
// RegisterBackupFailed records a failed backup.
|
2018-06-06 21:35:06 +00:00
|
|
|
func (m *ServerMetrics) RegisterBackupFailed(backupSchedule string) {
|
2018-10-23 21:04:45 +00:00
|
|
|
if c, ok := m.metrics[backupFailureTotal].(*prometheus.CounterVec); ok {
|
2018-06-06 21:35:06 +00:00
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-06 21:35:06 +00:00
|
|
|
}
|
2018-06-20 18:08:07 +00:00
|
|
|
|
|
|
|
// 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 {
|
|
|
|
c.WithLabelValues(backupSchedule).Observe(seconds)
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-20 18:08:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// toSeconds translates a time.Duration value into a float64
|
|
|
|
// representing the number of seconds in that duration.
|
|
|
|
func toSeconds(d time.Duration) float64 {
|
|
|
|
return float64(d / time.Second)
|
|
|
|
}
|
2018-06-25 18:15:46 +00:00
|
|
|
|
|
|
|
// RegisterRestoreAttempt records an attempt to restore a backup.
|
|
|
|
func (m *ServerMetrics) RegisterRestoreAttempt(backupSchedule string) {
|
|
|
|
if c, ok := m.metrics[restoreAttemptTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-25 18:15:46 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 20:49:47 +00:00
|
|
|
// RegisterRestoreSuccess records a successful (maybe partial) completion of a restore.
|
2018-06-25 18:15:46 +00:00
|
|
|
func (m *ServerMetrics) RegisterRestoreSuccess(backupSchedule string) {
|
|
|
|
if c, ok := m.metrics[restoreSuccessTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-25 18:15:46 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 20:49:47 +00:00
|
|
|
// RegisterRestoreFailed records a restore that failed.
|
|
|
|
func (m *ServerMetrics) RegisterRestoreFailed(backupSchedule string) {
|
|
|
|
if c, ok := m.metrics[restoreFailedTotal].(*prometheus.CounterVec); ok {
|
2018-06-25 18:15:46 +00:00
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-25 18:15:46 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 20:49:47 +00:00
|
|
|
// RegisterRestoreValidationFailed records a restore that failed validation.
|
2018-06-25 18:15:46 +00:00
|
|
|
func (m *ServerMetrics) RegisterRestoreValidationFailed(backupSchedule string) {
|
|
|
|
if c, ok := m.metrics[restoreValidationFailedTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Inc()
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-06-25 18:15:46 +00:00
|
|
|
}
|
2018-10-23 21:04:45 +00:00
|
|
|
|
|
|
|
// RegisterVolumeSnapshotAttempts records an attempt to snapshot a volume.
|
|
|
|
func (m *ServerMetrics) RegisterVolumeSnapshotAttempts(backupSchedule string, volumeSnapshotsAttempted int) {
|
|
|
|
if c, ok := m.metrics[volumeSnapshotAttemptTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsAttempted))
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-10-23 21:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterVolumeSnapshotSuccesses records a completed volume snapshot.
|
|
|
|
func (m *ServerMetrics) RegisterVolumeSnapshotSuccesses(backupSchedule string, volumeSnapshotsCompleted int) {
|
|
|
|
if c, ok := m.metrics[volumeSnapshotSuccessTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsCompleted))
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-10-23 21:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterVolumeSnapshotFailures records a failed volume snapshot.
|
|
|
|
func (m *ServerMetrics) RegisterVolumeSnapshotFailures(backupSchedule string, volumeSnapshotsFailed int) {
|
|
|
|
if c, ok := m.metrics[volumeSnapshotFailureTotal].(*prometheus.CounterVec); ok {
|
|
|
|
c.WithLabelValues(backupSchedule).Add(float64(volumeSnapshotsFailed))
|
|
|
|
}
|
2019-01-25 03:33:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// -------------------------------------------------------------------
|
2018-10-23 21:04:45 +00:00
|
|
|
}
|