Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor disk usage of kubernetes persistent volumes?

I have container_fs_usage_bytes with prometheus to monitor container root fs, but it seems that there is no metrics for other volumes in cAdvisor.

like image 646
hiroshi Avatar asked Jun 23 '17 09:06

hiroshi


People also ask

How do I monitor Kubernetes persistent volumes?

In the Dynatrace menu, go to Kubernetes and select your Kubernetes cluster. Select More (…) and go to Settings. Enable Monitor persistent volume claims (available only if your Kubernetes cluster is connected to a local Kubernetes API endpoint).

How do I monitor PVC usage?

To get the usage, create a debugging pod which will use your PVC, from which you will check the usage. This should work depending on your storage provider. Apply the above manifest with kubectl apply -f volume-size-debugger. yaml , and run a shell inside it with kubectl exec -it volume-size-debugger sh .

How do you check PV utilization in Kubernetes?

You could always use kubectl describe pv <pv-name> or kubectl get pv <pv-name> -o yaml . This might give you some information about the current state of the PV, but it might lack the information you need.


3 Answers

I confirmed that Kubernetes 1.8 expose metrics for prometheus.

  • kubelet_volume_stats_available_bytes
  • kubelet_volume_stats_capacity_bytes
  • kubelet_volume_stats_inodes
  • kubelet_volume_stats_inodes_free
  • kubelet_volume_stats_inodes_used
  • kubelet_volume_stats_used_bytes
like image 141
hiroshi Avatar answered Sep 28 '22 19:09

hiroshi


Metrics for volumes are available via the kubelet summary API (/stats/summary). However, each volume plugin has to implement their own metrics. As of Kubernetes 1.7, the current volume plugins that have implemented metrics include: emptydir, secrets, gce pd, aws ebs, azure file, flocker, and portworx

like image 42
Michelle Avatar answered Sep 28 '22 18:09

Michelle


The following metrics must be used for monitoring persistent volume stats in Kubernetes (the PVC name is exported in persistentvolumeclaim label):

  • kubelet_volume_stats_capacity_bytes - the per-PVC capacity in bytes.
  • kubelet_volume_stats_used_bytes - the per-PVC space usage in bytes.
  • kubelet_volume_stats_available_bytes - the per-PVC free space in bytes.

The following PromQL queries can be used for determining per-pod PVC disk space usage in bytes:

sum(kubelet_volume_stats_used_bytes) by (namespace,persistentvolumeclaim)
  * on(namespace,persistentvolumeclaim) group_left(pod)
kube_pod_spec_volumes_persistentvolumeclaims_info

The following query can be used for determining free PVC disk space in bytes per each pod:

sum(kubelet_volume_stats_available_bytes) by (namespace,persistentvolumeclaim)
  * on(namespace,persistentvolumeclaim) group_left(pod)
kube_pod_spec_volumes_persistentvolumeclaims_info
like image 2
valyala Avatar answered Sep 28 '22 19:09

valyala