how to get kubernetes deployment CPU Usage by promethues

11/7/2019

I built a promethues for my kubernetes, and it works well now. It can get node and container/pod cpu, memory data, but I don't know how to get the kubernetes CPU Usage in promethues. Because in my application, if pod restart, deployment will not get data before.

-- edselwang
kubernetes
prometheus
prometheus-operator

1 Answer

11/7/2019

A deployment is only an abstraction within the Kubernetes control plane, the things actually using CPU will all be pods. So you can use something like this container_cpu_usage_seconds_total{namespace="mynamespace", pod_name=~"mydeployment-.*"}.

-- coderanger
Source: StackOverflow