Persistent Volume usage is one of those Kubernetes metrics that nobody pays attention to... right up until a database suddenly stops accepting writes and everyone starts asking what happened.
As a Cloud or DevOps engineer, implementing a Persistent Volume (PV) monitoring dashboard should be considered mandatory. Whether you're running databases, Redis instances, or any other stateful application, keeping an eye on storage consumption can save you from unpleasant surprises and emergency troubleshooting sessions.
Persistent Volume Usage in Bytes
The following Prometheus query displays the amount of storage currently consumed by your Persistent Volumes:
kubelet_volume_stats_used_bytes{job="kubelet", metrics_path="/metrics"}
Since the metric is returned in bytes, Grafana can automatically convert it into more readable units such as MB, GB, or TB by selecting the appropriate unit in the panel settings.
Persistent Volume Usage in Bytes
If you want to know how close a volume is to becoming full, use the following query:
(kubelet_volume_stats_used_bytes{job="kubelet", metrics_path="/metrics"} / kubelet_volume_stats_capacity_bytes{job="kubelet", metrics_path="/metrics"}) * 100
This query divides the used storage by the total storage capacity and multiplies the result by 100 to calculate the percentage of space currently consumed.
For example:
A 100 GB volume using 25 GB will show 25%
A 100 GB volume using 80 GB will show 80%
Monitoring both the raw storage usage and percentage utilization gives you a complete picture of your Persistent Volumes and helps you identify growth trends before they become production incidents.
#grafana #prometheus
0 Comments