<p>I am trying to extract CPU usage per POD per node using Prometheus. I am currently using the following query:</p>
<pre><code>sum (rate (container_cpu_usage_seconds_total{kubernetes_io_hostname=&quot;$host&quot;,container!=&quot;&quot;,namespace=~&quot;default&quot;}[1m]))
/ sum (machine_cpu_cores{kubernetes_io_hostname=~&quot;$host&quot;}) * 100
</code></pre>
<p>However, this provides the CPU usage per node by all PODs. I tried grouping labels with the below:</p>
<pre><code>sum (sum(rate(container_cpu_usage_seconds_total{kubernetes_io_hostname=&quot;$host&quot;,container!=&quot;&quot;,namespace=~&quot;default&quot;}[2m]))
/ on (pod) group_left (kubernetes_io_hostname) (machine_cpu_cores{kubernetes_io_hostname=&quot;$host&quot;})) * 100
</code></pre>
<p>This gives me a similar output to 1st query in terms of percentage but it is still not separating it by POD.</p>
<p>Any suggestion how to get the correct value?</p>

Python_Rookie
<p>For those who are looking for a solution to this, @markalex has provided the answer</p>
<pre><code>sum by (pod) (rate (container_cpu_usage_seconds_total{kubernetes_io_hostname=&quot;$host&quot;,container!=&quot;&quot;,namespace=~&quot;default&quot;}[1m])) 
 / on() group_left() sum (machine_cpu_cores{kubernetes_io_hostname=~&quot;$host&quot;})
 * 100
</code></pre>
