Description
I have a long-standing issue that I'd like to consult about:
All containers are limited using Docker Compose with the following configuration:
deploy:
resources:
limits:
cpus: '1'
memory: 1G
Different containers with the same CPU limit exhibit different behaviors. When checking all containers with Docker, the result for "CpuQuota" is 0, which is expected since I haven’t set a specific CPU quota value. However, in cases where no quota is set, I’m seeing that some containers have container_spec_cpu_quota while others do not. This discrepancy is causing Prometheus to calculate the CPU usage for individual containers on the server as significantly high. The specific PromQL query I'm using is:
((sum by(instance, nodename, name) (rate(container_cpu_usage_seconds_total{name!=""}[1m])) / sum by(instance, nodename, name) (container_spec_cpu_quota{name!=""} / container_spec_cpu_period{name!=""})) * 100)