<p>I am scraping the kubernetes metrics from prometheus and would need to extract the number of running pods.</p>

<p>I can see container_last_seen metrics but how should i get no of pods running. Can someone help on this?</p>

MAG
<p>If you need to get number of running pods, you can use a metric from the list of pods metrics <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/docs/pod-metrics.md" rel="noreferrer">https://github.com/kubernetes/kube-state-metrics/blob/master/docs/pod-metrics.md</a> for that (To get the info purely on pods, it'd make sens to use pod-specific metrics).
For example if you need to get the number of pods per namespace, it'll be:
<code>count(kube_pod_info{namespace=&quot;$namespace_name&quot;}) by (namespace)</code>
To get the number of all pods running on the cluster, then just do:
<code>count(kube_pod_info)</code></p>
