Search code examples
prometheuspromql

How to filter label name after count_values in promql


enter image description here

a gauge named bag_status with label(a)

using

count_values ("bag_status" ,bag_status)

it will count number for diferent values

I want to filter bag_status with value <1

(count_values ("bag_status" ,bag_status)){bag_status!=1}

does not work


Solution

  • You could go about it the other way around. Just filter for the values you want before applying count_values:

    count_values("bag_status", bag_status < 1)