Skip to content

Unable to obtain "container_spec_cpu_quota" metrics #3601

Open

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions