Skip to content

Commit

Permalink
Adjust "volume name" label for kube_persistentvolumeclaim_*
Browse files Browse the repository at this point in the history
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
  • Loading branch information
multani committed Jan 13, 2024
1 parent 90bd24f commit 46e6dd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/store/persistentvolumeclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
8 changes: 4 additions & 4 deletions internal/store/persistentvolumeclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 46e6dd1

Please sign in to comment.