Search code examples
time-seriesprometheusmonitoringgrafanapromql

Ignore specific set of labels on prometheus query


I have a metric with 2 labels. Both labels can have 2 values A or B.

I'd like to sum all the values and exclude the case when Label1=A and Label2=B.

sum by (Label1,Label2)(metric{?})

Is it possible ?


Solution

  • Try the following query:

    sum by (Label1,Label2) (metric unless metric{Label1="A",Label2="B"})