How can I get correct metric for pod status?

12/29/2021

I'm trying to get the pod status in Grafana through Prometheus in a GKE cluster.

kube-state-metrics has been installed together with Prometheus by using the prometheus-community/prometheus and grafana Helm charts.

I tried to know the pod status through kube_pod_status_phase{exported_namespace=~".+-my-namespace", pod=~"my-server-.+"}, but I get only "Running" as a result. In other words, in the obtained graph I can see only a straight line at the value 1 for the running server. I can't get when the given pod was pending or in another state different from Running.

I am interested in the starting phase, after the pod is created, but before it is running.

Am I using the query correctly? Is there another query or it could be due to something in the installation?

-- sctx
google-kubernetes-engine
kube-state-metrics
kubernetes
prometheus
promql

1 Answer

12/29/2021

If you mean the Pending status for the Pod, I think you should use instead kube_pod_status_phase{exported_namespace=~".+-my-namespace", pod=~"my-server-.+", phase="Pending"} . Not sure what it does when you don't put the phase in your request but I suspect it just renders the number of Pods whatever the state is. In your case is always 1.

-- behanzin777
Source: StackOverflow