I am running a diskspace used query in Prometheus and would like to return only the top 5 or 10 entries from the search result. Is there anyway I can achieve that?
Currently, the query I am trying is returning me 58 entries
(100 - 100 * (node_filesystem_avail{device!~"by-uuid",device!~"tmpfs",mountpoint="/"} / node_filesystem_size{device!~"by-uuid",device!~"tmpfs",mountpoint="/"})) > 70
Just add topk(5, ...) in your query:
topk(5, (100 - 100 * (node_filesystem_avail{device!~"by-uuid",device!~"tmpfs",mountpoint="/"} / node_filesystem_size{device!~"by-uuid",device!~"tmpfs",mountpoint="/"})) > 70)