Skip to content

empty container field gives 2x sum in container_cpu_usage_seconds_total #2688

Closed as not planned

Description

@minrk

We have some grafana charts from promethus that look like:

sum(irate(container_cpu_usage_seconds_total{pod=~"name-.*"}[2m])) by (pod)

However, we noticed after a recent upgrade to GKE v1.17.9-gke.1504 (from 1.16) that resources seemed to spike, and it turns out that in addition to an entry for each container, there is matching entry with container undefined, which appears to be the sum of the actual containers, so our charts started reporting always ~2x the 'real' usage. Is there a recommended fix for this, or do we need to manually add ,container!="" to all of our queries to get accurate sums? Or am I misinterpreting what the undefined-container entry is?

The missing-container results are always missing container, image, name keys and are otherwise identical to the 'real' metrics.

Our prometheus is public, so you can see the results here.

I didn't find this exact issue searching for it, but happy for a close & link if this turns out to be a duplicate.

Activity

  1. minrk commented on Oct 2, 2020

    @minrk
    Author

    FWIW, container_memory_rss and presumably all container_ metrics are affected.

  2. paulfantom commented on Oct 2, 2020

    @paulfantom

    You need to add container!="POD" to your query.

    You can look at kubernetes-mixin project to get ready to use dashboards and alerts which are tested by others. Generated YAMLs can be obtained from https://monitoring.mixins.dev/kubernetes/

  3. inetkiller commented on Jul 29, 2022

    @inetkiller

    I also have the same problem

  4. fleetwoodstack commented on Nov 22, 2023

    @fleetwoodstack

    We have the exact same issue and I'm so surprised this isn't more recognised as a problem. It's caused double counting on any of our container metrics.

    Oddly ours only start displaying 12 hours in the past (metrics now aren't affected, but metrics older than 12 hours are)

  5. sidewinder12s commented on Feb 27, 2024

    @sidewinder12s

    This also ends up blowing up cardinality and metric series at scale, which is a major problem with almost all metrics providers.

  6. dims commented on Dec 9, 2025

    @dims
    Collaborator

    Closing this issue as it has been open since before January 1, 2024. If this is still relevant, please feel free to reopen or create a new issue.

  7. minrk commented on Dec 10, 2025

    @minrk
    Author

    @dims please reopen, I don't have permission to do that.

    I just checked and this issue persists in GKE 1.33.5-gke.1162000. It took no time or effort.

    It would be awesome if folks wouldn't waste so much time by closing persistent problems just because maintainers don't have time to fix them.

    Try the query:

    container_cpu_usage_seconds_total{pod="any-pod-name"}
    

    If I've misunderstood the metrics, that would be great, but as it appears, these metrics appear to just be counted twice, so any sums, etc. will get the wrong result.

  8. reopened this on Dec 10, 2025
  9. elatt commented on Jan 30, 2026

    @elatt

    You need to add container!="POD" to your query.

    You can look at kubernetes-mixin project to get ready to use dashboards and alerts which are tested by others. Generated YAMLs can be obtained from https://monitoring.mixins.dev/kubernetes/

    Is this true for all versions of cAdvisor? We have one cluster (OpenShift) where we see POD as the value for the container label but in the vast majority of our other clusters, it appears that container is just empty/not-set.

  10. github-actions commented on May 1, 2026

    @github-actions

    This issue is stale because it has been open 90 days with no activity. This issue will be closed in 30 days unless new comments are made or the stale label is removed. To skip these checks, apply the "lifecycle/frozen" label.

  11. added
    lifecycle/stale
    on May 1, 2026
  12. github-actions commented on May 31, 2026

    @github-actions

    This issue was automatically closed due to inactivity.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions