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 container_cpu_usage_seconds_total
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.
kube-state-metrics:
sum(kube_pod_container_resource_requests_cpu_cores) / sum(kube_node_status_allocatable_cpu_cores) * 100
- This gives 101%
whereas the kube-state-metrics gives 12%
which looks accurate to me.
kubernetes-api:
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
I don't think there's any metric in kube-state-metric which gives cpu usage compared to kubernetes-api
Thanks in advance.