Skip to content

Commit

Permalink
Merge pull request #128 from RaunakShah/add-metrics
Browse files Browse the repository at this point in the history
Add dataSource label to pvcs created
  • Loading branch information
k8s-ci-robot authored Jan 2, 2023
2 parents fa984d6 + 26ba34c commit ae1e8fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1284,14 +1284,18 @@ func (ctrl *ProvisionController) checkFinalizer(volume *v1.PersistentVolume, fin

func (ctrl *ProvisionController) updateProvisionStats(claim *v1.PersistentVolumeClaim, err error, startTime time.Time) {
class := ""
source := ""
if claim.Spec.StorageClassName != nil {
class = *claim.Spec.StorageClassName
}
if claim.Spec.DataSource != nil {
source = claim.Spec.DataSource.Kind
}
if err != nil {
ctrl.metrics.PersistentVolumeClaimProvisionFailedTotal.WithLabelValues(class).Inc()
ctrl.metrics.PersistentVolumeClaimProvisionFailedTotal.WithLabelValues(class, source).Inc()
} else {
ctrl.metrics.PersistentVolumeClaimProvisionDurationSeconds.WithLabelValues(class).Observe(time.Since(startTime).Seconds())
ctrl.metrics.PersistentVolumeClaimProvisionTotal.WithLabelValues(class).Inc()
ctrl.metrics.PersistentVolumeClaimProvisionDurationSeconds.WithLabelValues(class, source).Observe(time.Since(startTime).Seconds())
ctrl.metrics.PersistentVolumeClaimProvisionTotal.WithLabelValues(class, source).Inc()
}
}

Expand Down
12 changes: 6 additions & 6 deletions controller/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,26 @@ func New(subsystem string) Metrics {
prometheus.CounterOpts{
Subsystem: subsystem,
Name: "persistentvolumeclaim_provision_total",
Help: "Total number of persistent volumes provisioned succesfully. Broken down by storage class name.",
Help: "Total number of persistent volumes provisioned succesfully. Broken down by storage class name and source of the claim.",
},
[]string{"class"},
[]string{"class", "source"},
),
PersistentVolumeClaimProvisionFailedTotal: prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: subsystem,
Name: "persistentvolumeclaim_provision_failed_total",
Help: "Total number of persistent volume provision failed attempts. Broken down by storage class name.",
Help: "Total number of persistent volume provision failed attempts. Broken down by storage class name and source of the claim.",
},
[]string{"class"},
[]string{"class", "source"},
),
PersistentVolumeClaimProvisionDurationSeconds: prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Subsystem: subsystem,
Name: "persistentvolumeclaim_provision_duration_seconds",
Help: "Latency in seconds to provision persistent volumes. Failed provisioning attempts are ignored. Broken down by storage class name.",
Help: "Latency in seconds to provision persistent volumes. Failed provisioning attempts are ignored. Broken down by storage class name and source of the claim.",
Buckets: prometheus.DefBuckets,
},
[]string{"class"},
[]string{"class", "source"},
),
PersistentVolumeDeleteTotal: prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down

0 comments on commit ae1e8fb

Please sign in to comment.