title: PromQL query to show pod label in alert
body: <p>I have a default alert rule in Prometheus operator as below,</p>
  <pre><code>   - alert: KubePodNotReady
        annotations:
          message: Pod {{`{{`}} $labels.namespace {{`}}`}}/{{`{{`}} $labels.pod {{`}}`}} has been in a non-ready state for longer than 15 minutes.
          runbook_url: https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubepodnotready
        expr: |-
          sum by (namespace, pod) (
            max by(namespace, pod) (
              kube_pod_status_phase{job=&quot;kube-state-metrics&quot;, namespace=~&quot;.*&quot;, phase=~&quot;Pending|Unknown&quot;}
            ) * on(namespace, pod) group_left(owner_kind) topk by(namespace, pod) (
              1, max by(namespace, pod, owner_kind) (kube_pod_owner{owner_kind!=&quot;Job&quot;})
            )
          ) &gt; 0 
        for: 15m
        labels:
          severity: warning
  </code></pre>
  <p>I want the alert to show pod's label &quot;teamname&quot;.</p>
  <p>I am able to get the pod label with below expressions,</p>
  <pre><code>kube_pod_info * on(namespace, pod) group_left kube_pod_labels{label_teamname=&quot;example&quot;} 
  
  kube_pod_info * on(namespace, pod) group_left(label_teamname) kube_pod_labels
  </code></pre>
  <p>But I am not sure how to update the alert rule to display label.I just tried adding the label without editing expression,</p>
  <pre><code>  labels:
      severity: warning
      teamname: '{{ $labels.label_teamname }}'
  </code></pre>
  <p>But this didnt work.</p>
  <p>Is changing expression required that we can include teamname in the alert? If yes,kindly suggest how to change the below expression..</p>
  <pre><code>  expr: |-
      sum by (namespace, pod) (
        max by(namespace, pod) (
          kube_pod_status_phase{job=&quot;kube-state-metrics&quot;, namespace=~&quot;.*&quot;, phase=~&quot;Pending|Unknown&quot;}
        ) * on(namespace, pod) group_left(owner_kind) topk by(namespace, pod) (
          1, max by(namespace, pod, owner_kind) (kube_pod_owner{owner_kind!=&quot;Job&quot;})
        )
      ) &gt; 0 
  
   
  </code></pre>