Skip to content

Commit

Permalink
feat(metrics): add recurring job label to backup metrics or empty value
Browse files Browse the repository at this point in the history
Signed-off-by: Yvan <[email protected]>
  • Loading branch information
YvanGuidoin committed Jul 29, 2024
1 parent 4346be5 commit 43e9650
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions metrics_collector/backup_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewBackupCollector(
Desc: prometheus.NewDesc(
prometheus.BuildFQName(longhornName, subsystemBackup, "actual_size_bytes"),
"Actual size of this backup",
[]string{volumeLabel, backupLabel},
[]string{volumeLabel, backupLabel, recurringJobLabel},
nil,
),
Type: prometheus.GaugeValue,
Expand All @@ -42,7 +42,7 @@ func NewBackupCollector(
Desc: prometheus.NewDesc(
prometheus.BuildFQName(longhornName, subsystemBackup, "state"),
"State of this backup",
[]string{volumeLabel, backupLabel},
[]string{volumeLabel, backupLabel, recurringJobLabel},
nil,
),
Type: prometheus.GaugeValue,
Expand Down Expand Up @@ -79,8 +79,9 @@ func (bc *BackupCollector) Collect(ch chan<- prometheus.Metric) {
if !ok {
bc.logger.WithError(err).Warn("Error get backup volume label")
}
ch <- prometheus.MustNewConstMetric(bc.sizeMetric.Desc, bc.sizeMetric.Type, size, backupVolumeName, backup.Name)
ch <- prometheus.MustNewConstMetric(bc.stateMetric.Desc, bc.stateMetric.Type, float64(getBackupStateValue(backup)), backupVolumeName, backup.Name)
backupRecurringJobName := backup.Labels[types.RecurringJobLabel]
ch <- prometheus.MustNewConstMetric(bc.sizeMetric.Desc, bc.sizeMetric.Type, size, backupVolumeName, backup.Name, backupRecurringJobName)
ch <- prometheus.MustNewConstMetric(bc.stateMetric.Desc, bc.stateMetric.Type, float64(getBackupStateValue(backup)), backupVolumeName, backup.Name, backupRecurringJobName)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions metrics_collector/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
userCreatedLabel = "user_created"
backingImageLabel = "backing_image"
backupBackingImageLabel = "backup_backing_image"
recurringJobLabel = "recurring_job"
)

type metricInfo struct {
Expand Down

0 comments on commit 43e9650

Please sign in to comment.