kube-state-metrics icon indicating copy to clipboard operation
kube-state-metrics copied to clipboard

`kube_persistentvolume_*` and `kube_persistentvolumeclaim_*` should expose the volume name under the same label

Open multani opened this issue 1 year ago • 7 comments

What would you like to be added:

kube_persistentvolume_* metrics and kube_persistentvolumeclaim_* metrics should expose the "name of the volume" inside the same metric label.

Why is this needed:

It's a bit difficult at the moment to combine the Persistent Volume and Persistent Volume Claim metrics together to get, for instance, the "size" of the PVC in a specific namespace:

It's then difficult to combine both metrics together, and bring the PVC labels into the PV metric (or vice-versa) (see https://github.com/prometheus/prometheus/issues/2204)

Describe the solution you'd like

Rename one of the two label to have the same label as the other metric.

Additional context

I was trying to get the "size" of the PVCs with a query like this, but it doesn't work because it's not possible to join on different labels:

avg(kube_persistentvolume_capacity_bytes) by (persistentvolume)
* on (volumename) group_left (namespace, persistentvolumeclaim)
avg(kube_persistentvolumeclaim_info) by (namespace, persistentvolumeclaim, volumename)

multani avatar Dec 18 '23 14:12 multani

/assign @CatherineF-dev /traige accepted

dashpole avatar Jan 11 '24 17:01 dashpole

/traige accepted

@dashpole there's a typo here ;)

Also, I'm happy to help on this feature, if needed :+1:

multani avatar Jan 12 '24 09:01 multani

/triage accepted

dashpole avatar Jan 12 '24 14:01 dashpole

You can rename a metric label, as long as this metric is not marked as STABLE.

# HELP kube_persistentvolume_status_phase [STABLE] The phase indicates if a volume is available, bound to a claim,…
46

# HELP kube_persistentvolumeclaim_created Unix creation timestamp

Free feel to open a PR @multani, I can help review

CatherineF-dev avatar Jan 12 '24 16:01 CatherineF-dev

I created https://github.com/kubernetes/kube-state-metrics/pull/2303 to fix the issue.

Looking at the code base, it seems the volumeattachment-related metrics may have the same issue.

multani avatar Jan 13 '24 18:01 multani