How does binary operator vector matching work (`on`, `ignoring`, `group_left`)?
AdvancedConceptPromQL & Recording Rules
Answer
For a / b, Prometheus pairs series with identical label sets. To control it:
on(labels): match only on these labels.ignoring(labels): match on all labels except these.group_left/group_right: allow many-to-one matching and copy extra labels from the "one" side.
sum by (namespace, pod) (rate(container_cpu_usage_seconds_total[5m]))
* on (namespace, pod) group_left(team)
kube_pod_labels{label_team!=""}
The error many-to-many matching not allowed means the "one" side has duplicates for the match labels.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate