Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get total and free disk space using Prometheus

I try to get Total and Free disk space on my Kubernetes VM so I can display % of taken space on it. I tried various metrics that included "filesystem" in name but none of these displayed correct total disk size. Which one should be used to do so?

Here is a list of metrics I tried

node_filesystem_size_bytes
node_filesystem_avail_bytes
node:node_filesystem_usage:
node:node_filesystem_avail:
node_filesystem_files
node_filesystem_files_free
node_filesystem_free_bytes
node_filesystem_readonly
like image 286
Uliysess Avatar asked Aug 05 '19 11:08

Uliysess


2 Answers

According to my Grafana dashboard, the following metrics work nicely for alerting for available space,

100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype!="rootfs"} * 100) / node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"})

The formula gives out the percentage of available space on the pointed disk. Make sure you include the mountpoint and fstype within the metrics.

like image 124
AYA Avatar answered Sep 20 '22 11:09

AYA


FS utilization can be calculated as

100 - (100 * ((node_filesystem_avail_bytes{mountpoint="/",fstype!="rootfs"} )  / (node_filesystem_size_bytes{mountpoint="/",fstype!="rootfs"}) ))
like image 43
Krishnan Subramanian Avatar answered Sep 18 '22 11:09

Krishnan Subramanian