'How to create an alert for a pod running status in Prometheus

I have deployed prometheus, node exporter and alert manager on kubernetes and I am trying to create an alert rule to check if any specific pod is running or not. I am getting the metrics and right now I have created a rule in prometheus.rules files as below:

      - alert: utils Pod not running
        expr: sum(kube_pod_container_status_running{pod=~"utils"}) < 1
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: utils pod is not running (instance {{ $labels.pod }})

But is not working. Can anyone help in creating a rule for checking if any specific pod is running in cluster or not. I am new to this. Thank you in advance.



Solution 1:[1]

That worked for me: kube_pod_status_ready{condition="true",pod=~".*"}==0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Murat Kuru