Fix CPU unit in top consumers dashboard from percent to cores#378
Fix CPU unit in top consumers dashboard from percent to cores#378sradco wants to merge 1 commit into
Conversation
The "Top Consumers of CPU by virt-launcher Pods" panel was using percentunit to display the result of rate(container_cpu_usage_seconds_total). Since rate() on a CPU counter returns cores (seconds/second), a pod using 2 CPUs was incorrectly displayed as 200%. Change the table column unit from percentunit to short (plain number) and rename the alias to "CPU Usage (cores)". Also fix the time-series graph y-axis from seconds to short with a "cores" label for consistency. Signed-off-by: Shlomo Radco <sradco@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
@avlitman @machadovilaca please review this PR |
📝 WalkthroughWalkthroughThe PR updates the KubeVirt top-consumers Grafana dashboard to clarify CPU metrics display. A table field alias changed from "CPU Usage" to "CPU Usage (cores)" for improved clarity. An invalid unit value ("percentunit") was corrected to "short" on the same field. The CPU usage graph's y-axis was configured with a "cores" label and "short" format, ensuring consistent unit messaging across the dashboard. Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dashboards/openshift/kubevirt-top-consumers.json (1)
291-303: Cross-repository consistency needs attention.The linked repository findings show that
kubevirt/hyperconverged-cluster-operatorcontains multiple dashboard templates/copies of this same dashboard that still have the"unit": "percentunit"issue:
controllers/operandhandler/testFiles/dashboards/kubevirt-top-consumers.yamlcontrollers/handlers/testFiles/dashboards/kubevirt-top-consumers.yamlhack/testFiles/test_dashboard_cm.yamlassets/dashboards/grafana-dashboard-kubevirt-top-consumers.yamlAfter this PR merges, those downstream dashboards will display CPU metrics inconsistently (still showing "200%" for 2 cores). Consider opening a follow-up PR or issue in the hyperconverged-cluster-operator repository to apply the same unit/alias/y-axis fixes and maintain consistency across the KubeVirt dashboard ecosystem.
Also applies to: 1389-1390
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@dashboards/openshift/kubevirt-top-consumers.json` around lines 291 - 303, The dashboard JSON shows the CPU metric panel using alias "CPU Usage (cores)" but the unit was corrected here to "short" (and pattern "Value `#A`", type "number", decimals 2); ensure the same change is applied in downstream copies by replacing any occurrences of "unit": "percentunit" with "unit": "short" (and keep alias "CPU Usage (cores)", pattern "Value `#A`", type "number", decimals 2 and appropriate thresholds/y-axis settings) in the kubevirt/hyperconverged-cluster-operator dashboard templates so CPU values render as cores not percent—open a follow-up PR or issue against those files to propagate this exact fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@dashboards/openshift/kubevirt-top-consumers.json`:
- Around line 291-303: The dashboard JSON shows the CPU metric panel using alias
"CPU Usage (cores)" but the unit was corrected here to "short" (and pattern
"Value `#A`", type "number", decimals 2); ensure the same change is applied in
downstream copies by replacing any occurrences of "unit": "percentunit" with
"unit": "short" (and keep alias "CPU Usage (cores)", pattern "Value `#A`", type
"number", decimals 2 and appropriate thresholds/y-axis settings) in the
kubevirt/hyperconverged-cluster-operator dashboard templates so CPU values
render as cores not percent—open a follow-up PR or issue against those files to
propagate this exact fix.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 788645d2-02af-49d3-b7c4-c5170d4dda95
📒 Files selected for processing (1)
dashboards/openshift/kubevirt-top-consumers.json
HCO already has a |
|
@avlitman @machadovilaca please review this PR |
Summary
percentunittoshort(cores) and renamed the column alias to "CPU Usage (cores)"s(seconds) toshortwith a "cores" labelProblem
The query
rate(container_cpu_usage_seconds_total{container="compute",pod=~"virt-launcher-.*"})returns CPU usage in cores (seconds/second), but the panel was formatting the value as a percentage. A pod using 2 out of 8 assigned CPUs was displayed as "200%" instead of "2 cores".Test plan
2.00) not percent (e.g.200%)Made with Cursor