From 5099acb01f154313f0da662c47798680ba5bb2d3 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sat, 13 Jan 2024 19:02:22 +0100 Subject: [PATCH 1/3] 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. --- docs/persistentvolumeclaim-metrics.md | 2 +- internal/store/persistentvolumeclaim.go | 3 ++- internal/store/persistentvolumeclaim_test.go | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/persistentvolumeclaim-metrics.md b/docs/persistentvolumeclaim-metrics.md index 33e76d262e..fd7b25e911 100644 --- a/docs/persistentvolumeclaim-metrics.md +++ b/docs/persistentvolumeclaim-metrics.md @@ -4,7 +4,7 @@ | ---------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | | kube_persistentvolumeclaim_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](./cli-arguments.md) | | `persistentvolumeclaim`=<persistentvolumeclaim-name>
`namespace`=<persistentvolumeclaim-namespace>
`annotation_PERSISTENTVOLUMECLAIM_ANNOTATION`=<PERSISTENTVOLUMECLAIM_ANNOATION> | EXPERIMENTAL | | kube_persistentvolumeclaim_access_mode | Gauge | | | `access_mode`=<persistentvolumeclaim-access-mode>
`namespace`=<persistentvolumeclaim-namespace>
`persistentvolumeclaim`=<persistentvolumeclaim-name> | STABLE | -| kube_persistentvolumeclaim_info | Gauge | | | `namespace`=<persistentvolumeclaim-namespace>
`persistentvolumeclaim`=<persistentvolumeclaim-name>
`storageclass`=<persistentvolumeclaim-storageclassname>
`volumename`=<volumename>
`volumemode`=<volumemode> | STABLE | +| kube_persistentvolumeclaim_info | Gauge | | | `namespace`=<persistentvolumeclaim-namespace>
`persistentvolumeclaim`=<persistentvolumeclaim-name>
`storageclass`=<persistentvolumeclaim-storageclassname>
`persistentvolume`=<volumename>
`volumemode`=<volumemode> | STABLE | | kube_persistentvolumeclaim_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](./cli-arguments.md) | | `persistentvolumeclaim`=<persistentvolumeclaim-name>
`namespace`=<persistentvolumeclaim-namespace>
`label_PERSISTENTVOLUMECLAIM_LABEL`=<PERSISTENTVOLUMECLAIM_LABEL> | STABLE | | kube_persistentvolumeclaim_resource_requests_storage_bytes | Gauge | | | `namespace`=<persistentvolumeclaim-namespace>
`persistentvolumeclaim`=<persistentvolumeclaim-name> | STABLE | | kube_persistentvolumeclaim_status_condition | Gauge | | | `namespace` =<persistentvolumeclaim-namespace>
`persistentvolumeclaim`=<persistentvolumeclaim-name>
`type`=<persistentvolumeclaim-condition-type>
`status`=<true\false\unknown> | EXPERIMENTAL | 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 From dbf9c85717c84d1f82fa4391a3ec57473a625257 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sat, 13 Jan 2024 21:47:31 +0100 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bbad6ba89..700ea1232a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Next: + +### Note + +* [BUGFIX] Change `volumename` label to `persistentvolume` in `kube_persistentvolumeclaim_*` metrics by @multani in + ## v2.11.0 / 2024-03-04 ### Note From dc8144f325b786b6fea6b79b79c9d1140e2d4cb1 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Fri, 26 Jan 2024 09:53:15 +0100 Subject: [PATCH 3/3] lint markdown --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 700ea1232a..7d007afff1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Next: +## Next ### Note