Excluding a label value from a specific host only

Viewed 235

I've below metrics in Prometheus

{hostname="HOST-A",mountpoint="/DIR/1"} 0
{hostname="HOST-B",mountpoint="/DIR/2"} 0
{hostname="HOST-B",mountpoint="/DIR/7"} 0
{hostname="HOST-C",mountpoint="/DIR/3"} 0
{hostname="HOST-D",mountpoint="/DIR/4"} 0

How can I exclude a specific mount point from a single host only?

I use below expresson to get FS utilization 100 - (100 * node_filesystem_avail_bytes / node_filesystem_size_bytes)

Trying to achieve is exclude a specific host and all content inside a mount point. From hostname="HOST-B" and mountpoint="/DIR/.*"

current expr: 100 - (100 * node_filesystem_avail_bytes{hostname="HOST-B",mountpoint!~"/DIR/.*"} / node_filesystem_size_bytes{hostname="HOST-B",mountpoint!~"/DIR/.*"})

How can we modify the expression and incldue other host to the metrics returned from Prometheus

1 Answers

Inorder to excldue a specific mountpoint value from a specific hostname,you can use unless operator of promQL to achieve this.

Query to filter out :

node_filesystem_avail_bytes unless node_filesystem_avail_bytes{hostname="HOST-B", mountpoint="/DIR/1"}

The above query will show available bytes of all hosts & mountpoints except host-B with mountpoint DIR/1

Related