Skip to content

fix(dashboards): group pod resource requests and limits by containerfix(dashboards): group pod resource requests and limits by container#1180

Open
Cloud-Architect-Emma wants to merge 4 commits intokubernetes-monitoring:masterfrom
Cloud-Architect-Emma:fix-pod-resource-aggregation
Open

fix(dashboards): group pod resource requests and limits by containerfix(dashboards): group pod resource requests and limits by container#1180
Cloud-Architect-Emma wants to merge 4 commits intokubernetes-monitoring:masterfrom
Cloud-Architect-Emma:fix-pod-resource-aggregation

Conversation

@Cloud-Architect-Emma
Copy link

Problem
In the "Compute Resources / Pod" dashboard, the CPU/Memory Request and Limit lines are currently aggregated at the Pod level (summed together). On pods with multiple containers (like sidecars or service meshes), this creates a single line that doesn't align with the individual "Usage" lines, making it impossible to see which container is hitting its specific limit.

Solution
This PR adds by (container) to the following query functions in dashboards/resources/queries/pod.libsonnet:

  • cpuRequests
  • cpuLimits
  • memoryRequests
  • memoryLimits

This aligns the graph logic with the existing table queries in the same file which already use container-level grouping.

Validation
Verified that the PromQL sum() functions now include the by (container) clause to preserve the container label in the output series.

@skl
Copy link
Collaborator

skl commented Feb 20, 2026

I understand your point, but with your suggested change this graph is equally confusing as there are as many requests and limits series as there are containers:

Screenshot 2026-02-20 at 14 28 03

The tables have a row per container as you've pointed out, with usage/requests shown as a percentage.

The CPUThrottlingHigh alert and its panel here should also highlight which container is affected.

I would suggest that if you want to visualise this on a per-container basis, maybe add a container variable to the dashboard so that all panels can be filtered to a single container.

@Cloud-Architect-Emma
Copy link
Author

Thanks for the feedback, @skl! That makes complete sense, I see how the graph could become overcrowded with too many series. I like the idea of adding a container variable to filter the entire dashboard instead. I'll look into adding that variable and updating the panels to support it. I'll update this PR once I have a new version ready.

@Cloud-Architect-Emma
Copy link
Author

@skl I've updated the PR! I added a $container template variable in common.libsonnet and linked it through variables/pod.libsonnet. I also kept the by (container) aggregation in the queries so that when a specific container is selected via the dropdown, the request/limit lines accurately reflect that container's settings. Let me know what you think!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants