title: How to calculate cpu usage of pod in kube state metrics?
body: <p>I monitor the eks cluster using both the kubernetes api and the kube state metrics remotely using prometheus.
  in Kubernetes api we have a metrics <strong><code>container_cpu_usage_seconds_total</code></strong> which gives the cpu usage of the pod.
  is there a similar metrics in kube-state-metrics which can give the cpu usage.
  Actually I'm trying to get the cluster cpu usage which is totally different from kubernetes api and kube-state-metrics
  following are the calculations.</p>
  
  <p><strong><code>kube-state-metrics:</code></strong></p>
  
  <p><code>sum(kube_pod_container_resource_requests_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores) * 100</code> - This gives 101%</p>
  
  <p>whereas the kube-state-metrics gives <code>12%</code> which looks accurate to me.</p>
  
  <p><strong><code>kubernetes-api:</code></strong></p>
  
  <p><code>sum (rate (container_cpu_usage_seconds_total{id="/",kubernetes_io_hostname=~"^$Node$",  job=~"$job$"}[5m])) / sum (machine_cpu_cores{kubernetes_io_hostname=~"^$Node$",  job=~"$job$"}) * 100</code></p>
  
  <p>I don't think there's any metric in kube-state-metric which gives cpu usage compared to kubernetes-api</p>
  
  <p>Thanks in advance.</p>