From 46e6dd1e78f363400a3e0d89d5c48d9935725377 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sat, 13 Jan 2024 19:02:22 +0100 Subject: [PATCH] Adjust "volume name" label for kube_persistentvolumeclaim_* This changes the name of the volume name label, reported by the `kube_persistentvolumeclaim_*` metrics, to be the same label as the one in the `kube_persistentvolume_*` metrics. This makes it easier to combine the 2 related set of metrics together to being labels and values from one metric into another. Closes: #2288 --- internal/store/persistentvolumeclaim.go | 3 ++- internal/store/persistentvolumeclaim_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/store/persistentvolumeclaim.go b/internal/store/persistentvolumeclaim.go index a8f7cdedc2..ad0e007136 100644 --- a/internal/store/persistentvolumeclaim.go +++ b/internal/store/persistentvolumeclaim.go @@ -104,7 +104,8 @@ func persistentVolumeClaimMetricFamilies(allowAnnotationsList, allowLabelsList [ return &metric.Family{ Metrics: []*metric.Metric{ { - LabelKeys: []string{"storageclass", "volumename", "volumemode"}, + // Matches the labels from kube_persistentvolume_* + LabelKeys: []string{"storageclass", "persistentvolume", "volumemode"}, LabelValues: []string{storageClassName, volumeName, volumeMode}, Value: 1, }, diff --git a/internal/store/persistentvolumeclaim_test.go b/internal/store/persistentvolumeclaim_test.go index f78ea88d15..2a87f14a74 100644 --- a/internal/store/persistentvolumeclaim_test.go +++ b/internal/store/persistentvolumeclaim_test.go @@ -86,7 +86,7 @@ func TestPersistentVolumeClaimStore(t *testing.T) { # TYPE kube_persistentvolumeclaim_status_phase gauge # TYPE kube_persistentvolumeclaim_status_condition gauge kube_persistentvolumeclaim_created{namespace="default",persistentvolumeclaim="mysql-data"} 1.5e+09 - kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="mysql-data",storageclass="rbd",volumename="pvc-mysql-data",volumemode="Block"} 1 + kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="mysql-data",storageclass="rbd",persistentvolume="pvc-mysql-data",volumemode="Block"} 1 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Bound"} 1 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Lost"} 0 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Pending"} 0 @@ -158,7 +158,7 @@ func TestPersistentVolumeClaimStore(t *testing.T) { # TYPE kube_persistentvolumeclaim_status_phase gauge # TYPE kube_persistentvolumeclaim_status_condition gauge kube_persistentvolumeclaim_created{namespace="default",persistentvolumeclaim="mysql-data"} 1.5e+09 - kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="mysql-data",storageclass="rbd",volumename="pvc-mysql-data",volumemode="Block"} 1 + kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="mysql-data",storageclass="rbd",persistentvolume="pvc-mysql-data",volumemode="Block"} 1 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Bound"} 1 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Lost"} 0 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="mysql-data",phase="Pending"} 0 @@ -212,7 +212,7 @@ func TestPersistentVolumeClaimStore(t *testing.T) { # TYPE kube_persistentvolumeclaim_status_phase gauge # TYPE kube_persistentvolumeclaim_status_condition gauge kube_persistentvolumeclaim_created{namespace="default",persistentvolumeclaim="prometheus-data"} 1.5e+09 - kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="prometheus-data",storageclass="rbd",volumename="pvc-prometheus-data",volumemode="Block"} 1 + kube_persistentvolumeclaim_info{namespace="default",persistentvolumeclaim="prometheus-data",storageclass="rbd",persistentvolume="pvc-prometheus-data",volumemode="Block"} 1 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="prometheus-data",phase="Bound"} 0 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="prometheus-data",phase="Lost"} 0 kube_persistentvolumeclaim_status_phase{namespace="default",persistentvolumeclaim="prometheus-data",phase="Pending"} 1 @@ -259,7 +259,7 @@ func TestPersistentVolumeClaimStore(t *testing.T) { # TYPE kube_persistentvolumeclaim_status_phase gauge # TYPE kube_persistentvolumeclaim_status_condition gauge kube_persistentvolumeclaim_created{namespace="",persistentvolumeclaim="mongo-data"} 1.5e+09 - kube_persistentvolumeclaim_info{namespace="",persistentvolumeclaim="mongo-data",storageclass="",volumename="",volumemode="Block"} 1 + kube_persistentvolumeclaim_info{namespace="",persistentvolumeclaim="mongo-data",storageclass="",persistentvolume="",volumemode="Block"} 1 kube_persistentvolumeclaim_status_phase{namespace="",persistentvolumeclaim="mongo-data",phase="Bound"} 0 kube_persistentvolumeclaim_status_phase{namespace="",persistentvolumeclaim="mongo-data",phase="Lost"} 1 kube_persistentvolumeclaim_status_phase{namespace="",persistentvolumeclaim="mongo-data",phase="Pending"} 0