Monitoring PVC Usage with Prometheus
Asked Answered
M

2

7

I am using Prometheus 2.33 version. The following query does not work.

kubelet_volume_stats_available_bytes

kubelet_volume_stats_capacity_bytes

The following query is used to monitor the DISK usage of the POD.

container_fs_usage_bytes

container_fs_limit_bytes

Is there a way to get the usage of PVC, Limit value?

Mckinley answered 11/2, 2022 at 2:2 Comment(0)
D
5

You can utilize two metrics to monitor your Persistent Volume Claims (PVCs), despite the name "volume" being used. The metrics are as follows:

  • kubelet_volume_stats_capacity_bytes: This metric indicates the total capacity of the volume.
  • kubelet_volume_stats_used_bytes: This metric represents the current usage of the volume.

To specify a particular PVC, you can employ the filter persistentvolumeclaim="PVC_NAME" and replace "PVC_NAME" with the actual name of your PVC.

For instance, you can calculate the usage percentage using the following query:

100.0 * kubelet_volume_stats_used_bytes{job="kubelet", namespace="btel", persistentvolumeclaim="storage-volume-cpro-server-1"} / kubelet_volume_stats_capacity_bytes

This query provides the usage percentage for the PVC named "storage-volume-cpro-server-1" in the "btel" namespace, based on the kubelet_volume_stats_used_bytes and kubelet_volume_stats_capacity_bytes metrics.

Deferment answered 11/7, 2023 at 15:54 Comment(0)
J
1

For PVC, Kubernetes exposes these metrics to Prometheus, you can use them to monitor a persistent volume's usage:

kube_persistentvolume_capacity_bytes 
kube_persistentvolumeclaim_resource_requests_storage_bytes

EDIT: These metrics are from kube-state-metrics - a service that produces Prometheus format metrics based on the current state of the Kubernetes native resources. It is basically listening to Kubernetes API and gathering information about its resources and objects, in particular for PV - PV metrics and PVC - PVC metrics. More information about the service is here.

Joy answered 11/2, 2022 at 15:1 Comment(2)
Is there a guide or document for "Kube_PersisitTVolumeclaim_Capacity_Bytes" I can not even search.Ikon
@김태우 my apologies, I've misspelled the metrics' names. I've edited the answer, please check.Joy

© 2022 - 2024 — McMap. All rights reserved.