I have two range vectors (# of hits and misses) that I want to aggregate by their types. Some of the types have hits, other misses, some with both. These are two independant metrics that I'm trying to get a union of but the resulting vector doesn't make sense. It's missing some of the values and I think it's because they have either all hits or misses. Am I doing this completely the wrong way?
sum by (type) (increase(metric_hit{}[24h]) + sum by (type) (increase(metric_miss{}[24h])
First off, it's recommended to always initialise all your potential label values to avoid this sort of issue.
This can be handled with the or
operator:
sum by (type) (
(increase(metric_hit[1d]) or metric_miss * 0)
+
(increase(metric_miss[1d]) or metric_hit * 0)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With