<p>I try to calculate how many percent cpu of limits pod use. I try to use this expression:</p>

<pre><code>sum(irate(container_cpu_usage_seconds_total{cluster!="production",namespace="devops"}[2m])) by (pod_name) / kube_pod_container_resource_limits_cpu_cores{cluster!="production",namespace="devops"}
</code></pre>

<p>But it show 0 series. Left and right sided expressions return scalar values.</p>

<p>You can use below prometheus expression to give percentage CPU usage -</p>
<pre><code>sum(rate(container_cpu_usage_seconds_total{container_name=&quot;abc&quot;}[5m])) by (container_name) /sum(container_spec_cpu_quota{container_name=&quot;abc&quot;}/container_spec_cpu_period{container_name=&quot;abc&quot;}) by (container_name) *100 
</code></pre>
<p>You can create your own custom dashboard in Grafana to get the data for last <code>x</code> number of days.</p>
