title: Prometheus - many-to-many matching not allowed
body: <p>I’m trying to use for the first time vector matching and I’m getting an error saying “many-to-many matching not allowed: matching labels must be unique on one side” and I don’t understand why.</p>
  
  <p>Here is my expression :</p>
  
  <pre><code>sum(rate(container_cpu_usage_seconds_total{image!="",pod_name=~"sentry.*",container_name!="POD"}[5m])) by (container_name) 
  * on (container_name) group_left(container) 
  avg by (container) (kube_pod_container_resource_requests_cpu_cores{container=~"sentry.*"})
  </code></pre>
  
  <p>The result for both vector is</p>
  
  <pre><code>sum(rate(container_cpu_usage_seconds_total{image!=“”,pod_name=~“sentry.*“,container_name!=“POD”}[5m])) by (pod_name, namespace,container_name)
  
  
  {container_name="sentry-web",namespace="infrastructure",pod_name="sentry-web-65757bf8f6-cgmsw"}
  {container_name="sentry-statsds",namespace="infrastructure",pod_name="sentry-statsd-849699fb56-jnljm"}
  {container_name="sentry-k8s",namespace="infrastructure",pod_name="sentry-k8s-66b9b88758-stn5x"}
  {container_name="sentry-cron",namespace="infrastructure",pod_name="sentry-cron-7dcdfc5688-qh55k"}
  {container_name="redis-exporter",namespace="infrastructure",pod_name="sentry-redis-exporter-779f4f85cb-clmc7"}
  {container_name="rds-exporter",namespace="infrastructure",pod_name="sentry-rds-exporter-54bb4dcd8d-h5rh5"}
  {container_name="nginx-exporter",namespace="infrastructure",pod_name="sentry-web-75959bc475-4dpg2"}
  {container_name="nginx-exporter",namespace="infrastructure",pod_name="sentry-web-65757bf8f6-cgmsw"}
  {container_name="nginx",namespace="infrastructure",pod_name="sentry-web-75959bc475-4dpg2"}
  </code></pre>
  
  <p><code>avg by (container) (kube_pod_container_resource_requests_cpu_cores{container=~“sentry.*“})</code></p>
  
  <pre><code>{container="sentry-k8s"}    0.1
  {container="sentry-statsds"}    0.1
  {container="sentry-cron"}    0.1
  {container="sentry-workers"}    0.5
  {container="sentry-web"}    1
  </code></pre>
  
  <p>The second vector have uniq labels so why I’m getting this error ? Any ideas ?</p>