Skip to content

Fix CPU unit in top consumers dashboard from percent to cores#378

Open
sradco wants to merge 1 commit into
kubevirt:mainfrom
sradco:fix-cpu-unit-top-consumers
Open

Fix CPU unit in top consumers dashboard from percent to cores#378
sradco wants to merge 1 commit into
kubevirt:mainfrom
sradco:fix-cpu-unit-top-consumers

Conversation

@sradco
Copy link
Copy Markdown
Collaborator

@sradco sradco commented May 25, 2026

Summary

  • Changed the "Top Consumers of CPU by virt-launcher Pods" table panel unit from percentunit to short (cores) and renamed the column alias to "CPU Usage (cores)"
  • Fixed the "CPU Usage by virt-launcher Pods" time-series graph y-axis from s (seconds) to short with a "cores" label

Problem

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

  • Open Observe > Dashboards > "KubeVirt / Infrastructure Resources / Top Consumers"
  • Verify "Top Consumers of CPU by virt-launcher Pods" table shows values in cores (e.g. 2.00) not percent (e.g. 200%)
  • Verify "CPU Usage by virt-launcher Pods" time-series graph y-axis is labeled "cores" with correct numeric values
  • Confirm values align with the overview dashboard (CNV-67879)

Made with Cursor

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>
@kubevirt-bot kubevirt-bot added the dco-signoff: yes Indicates the PR's author has DCO signed all their commits. label May 25, 2026
@sradco
Copy link
Copy Markdown
Collaborator Author

sradco commented May 25, 2026

@avlitman @machadovilaca please review this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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-operator contains multiple dashboard templates/copies of this same dashboard that still have the "unit": "percentunit" issue:

  • controllers/operandhandler/testFiles/dashboards/kubevirt-top-consumers.yaml
  • controllers/handlers/testFiles/dashboards/kubevirt-top-consumers.yaml
  • hack/testFiles/test_dashboard_cm.yaml
  • assets/dashboards/grafana-dashboard-kubevirt-top-consumers.yaml

After 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ae6055 and 0f72c98.

📒 Files selected for processing (1)
  • dashboards/openshift/kubevirt-top-consumers.json

@sradco
Copy link
Copy Markdown
Collaborator Author

sradco commented May 25, 2026

🧹 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-operator contains multiple dashboard templates/copies of this same dashboard that still have the "unit": "percentunit" issue:

  • controllers/operandhandler/testFiles/dashboards/kubevirt-top-consumers.yaml
  • controllers/handlers/testFiles/dashboards/kubevirt-top-consumers.yaml
  • hack/testFiles/test_dashboard_cm.yaml
  • assets/dashboards/grafana-dashboard-kubevirt-top-consumers.yaml

After 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

HCO already has a .github/workflows/dashboard-updater.yml that handles syncing the dashboard automatically from kubevirt/monitoring. So once this PR #378 merges, the GitHub Action will propagate the fix to all the downstream copies in HCO automatically.

@sradco
Copy link
Copy Markdown
Collaborator Author

sradco commented May 26, 2026

@avlitman @machadovilaca please review this PR

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

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants