'Would psutil.cpu_percentage depict a true CPU usage of a docker container running in Kubernetes?
I want to monitor CPU percentage usage of a Docker container and get alerted when it reaches a certain threshold.
My application is running in a Docker container, that is running in a Kubernetes pod.
What should be my concern - monitor
the CPU usage of the pod, right?
The incident was not being able to connect to the application because the CPU was swamped, and the deduction of the CPU being swamped was made by entering and topping the container.
Solution 1:[1]
The psuitl.Process.cpu_percent
calculates the unix-style utilization, this style sums the per-core utilization so you can use it to check your cpu utilization.
Also, you can use docker stats
command to live stream a container’s runtime metrics, and there is a graphical tool cAdvisor (Container Advisor) that could help you to understand the resource usage and performance on your containers.
You can find a guide on how to deploy Prometheus and cAdvisor in this link . There are other tools like scout that also helps to get alerts, but you will need to pay to use it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |