Consider the metrics:
foo{a="a"} 1
foo{a="b"} 1
bar{a="b"} 1
bar{a="c"} 1
The query
sum by (a) (foo) + sum by (a) (bar)
returns
{a="b"} 2
What I would like is a query that will treat the absence of a given set of labels on the other side of the sum as 0. Essentially I need a query with the following result:
{a="a"} 1
{a="b"} 2
{a="c"} 1
Prometheus is lacking outer join functionality. You can see very in-depth description of situation and possible workaround for
left outer joinfrom Brian Brazil here.Based on the same logic
full outer joinfor your example will look like this: