Interview Prep/Monitoring & Observability/PromQL and recording rules

Binary operation fails: `many-to-many matching not allowed: matching labels must be unique on one side`

AdvancedTroubleshootingPromQL and recording rules
Answer

Likely causes → Both sides have multiple series per match group, often when joining with kube_pod_info or kube_pod_labels which can have duplicates during pod restarts or from two kube-state-metrics replicas.

Diagnose →

count by (namespace, pod) (kube_pod_info) > 1

Fix → Aggregate the "one" side first and use explicit matching:

sum by (namespace, pod) (rate(container_cpu_usage_seconds_total[5m]))
  * on (namespace, pod) group_left(node)
  max by (namespace, pod, node) (kube_pod_info)

Prevent → Run one kube-state-metrics per cluster (or shard properly) and always wrap join sides in max by.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on PromQL and recording rules