Getting container resource metrics from kubernetes cluster

4/4/2019

I am exploring client-go library for collecting resource metric for a kubernetes cluster. I am more keen on collecting the container metrics from all the pods.

But according to the wiki, https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/, i see that we can only get pod or node level metrics and not container level metrics.

Is there a way i can collect container level metric (like the way docker api gives the metrics for a container)?

-- Venkat Teki
client-go
kubernetes

1 Answer

4/4/2019

You should deploy the External Metric server like Prometheus Adapter (example of full metric solution mentioned in official doc you linked).

The quickest way to achieve it is via kube-prometheus repository, which is part of prometheus-operator project. It already includes kube-state-metrics, which generates custom metrics of your interest (Pod Metrics), example of container related one: kube_pod_container_resource_requests_cpu_cores.

-- Nepomucen
Source: StackOverflow