How to write regex at varaible, Ex: pod running

label_values(kube_pod_status_phase{namespace=~"$namespace",cluster="$cluster",phase=“Running”},pod)

This shows all pod which includes, failed and couple of pods are repeating.

Actually I need to run above query, means running pod in the cluster?
kube_pod_status_phase{cluster=“isoft”,phase=“Running”}>0 this query returns running pod

The label_values function extracts labels from a Prometheus metric for using in template variables in Grafana. The second parameter specifics which label (pod in your case) will return a list of pod names which have are in the Running phase - otherwise something is wrong.

How are you using the label_values function in your dashboard?

1 Like