How to set a Prometheus alert if a specific pod is not in running the state?

Hello, can someone help on how to set a Prometheus alert if a specific pod is not in running the state?

basically, this pod that needs to be monitored has a static prefix podname i.e sam-xxxxxxxxx and the suffix will be changed when it gets recreated for some reason. so ideally this needs to be handled by wild card sam-* but it is not working


container_last_seen{beta_kubernetes_io_arch="amd64",beta_kubernetes_io_os="linux",container="POD",id="/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podec4a0ea3_51ef_4945_a62c_0a70e4330603.slice/docker-731d2e11bafdf6fb02d69a070e76bd1fdf51ccdb89a27433b02d5760bc88ca0c.scope",image="<http://k8s.gcr.io/pause:3.2|k8s.gcr.io/pause:3.2>",instance="sam01",job="kubernetes-nodes-cadvisor",kubernetes_io_arch="amd64",kubernetes_io_hostname="sam01",kubernetes_io_os="linux",name="k8s_POD_sam-757f7855c6-k5snd_default_ec4a0ea3-51ef-4945-a62c-0a70e4330603_0",namespace="default",pod="sam-757f7855c6-k5snd"}

container_last_seen{pod="sam-*"}```

Have you tried, {pod~=“sam.*”}?