<p>I have multiple <code>prometheusRules(rule a, rule b)</code>, and each rule defined different exp to constraint the alert; then, I have different <code>AlertmanagerConfig</code>(one receiver is slack, then other one's receiver is <code>opsgenie</code>); How can we make a connection between rules and <code>alertmanagerconfig</code>? for example: if rule a is triggered, I want to send message to slack; if rule b is triggered, I want to send message to <code>opsgenie</code>.</p>
<p>Here is what I tried, however, that does not work. Did I miss something?</p>
<p>This is <code>prometheuisRule</code> file</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    prometheus: service-prometheus
    role: alert-rules
    app: kube-prometheus-stack
    release: monitoring-prom
  name: rule_a
  namespace: monitoring
spec:
  groups:
    - name: rule_a_alert
      rules:
        - alert: usage_exceed
          expr: salesforce_api_usage &gt; 100000
          labels:
            severity: urgent

</code></pre>
<p>This is <code>alertManagerConfig</code></p>
<pre><code>apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  labels:
    alertmanagerConfig: slack
  name: slack
  namespace: monitoring
  resourceVersion: &quot;25842935&quot;
  selfLink: /apis/monitoring.coreos.com/v1alpha1/namespaces/monitoring/alertmanagerconfigs/opsgenie-and-slack
  uid: fbb74924-5186-4929-b363-8c056e401921
spec:
  receivers:
  - name: slack-receiver
    slackConfigs:
    - apiURL:
        key: apiURL
        name: slack-config
  route:
    groupBy:
    - job
    groupInterval: 60s
    groupWait: 60s
    receiver: slack-receiver
    repeatInterval: 1m
    routes:
    - matchers:
      - name: job
        value: service_a
      receiver: slack-receiver

</code></pre>

<p>You need to match on a label of the alert, in your case you're trying to match on the label <code>job</code> with the value <code>service_a</code> which doesn't exist.  You could either match on a label that does exist in the prometheuisRule file, eg <code>severity</code>, by changing the <code>match</code> in the alertManagerConfig file:</p>
<pre><code>route:
  routes:
  - match:
      severity: urgent
    receiver: slack-receiver
</code></pre>
<p>or you could add another label to the prometheuisRule file:</p>
<pre><code>spec:
  groups:
    - name: rule_a_alert
      rules:
        - alert: usage_exceed
          expr: salesforce_api_usage &gt; 100000
          labels:
            severity: urgent
            job: service_a
</code></pre>
