Considering the simple promQL:
sum(metric_name{label="some label value"}) by (label, another_label)
I get this graph displayed:
I know that my metric_name has data for two label values for another_label, e.g. another value1 and another value2, but only the line for another value1 is displayed, because for this time interval, there is/might be no data for another value2.
What I want to achieve is to see the second line for another value2 displayed as 0.
I tried:
sum(metric_name{label="some label value"} or on() vector(0)) by (label, another_label)
No luck, then I tried with a trick:
sum(
metric_name{label="some label value"}
or (absent(metric_name{label="some label value", another_label="another value2"}) - 1)
) by (label, another_label)
This worked as expected:
But as you can imagine I don't want to manually chain these absent conditions for every existing label value of another_label, especially that I know that these won't be just two in reality.
- Can I somehow generalize the
absentcondition likeor (absent(metric_name{label="some label value", another_label="<foreach>"}) - 1)? - Is there some other way to fill these gaps with 0?