Skip to content

fix(dashboard): read docker_stats container CPU as percent of one core - #326

Merged
vishr merged 1 commit into
mainfrom
fix/container-cpu
Oct 16, 2026
Merged

vishr merged 1 commit into
mainfrom
fix/container-cpu

Conversation

@vishr

@vishr vishr commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

On OpenTelemetry Demo data the Containers panel showed CPU of 19,309% (load-generator) and 1,367% (payment), and every container was bad.

The panel multiplied container.cpu.utilization by 100 whenever its unit was "1". docker_stats, the receiver the panel names as its source, computes the value the way docker stats does (cpuDelta / systemDelta * onlineCPUs * 100). The value is already a percentage of one core, even though the receiver declares unit "1". On the snapshot the scope is dockerstatsreceiver 0.160.0, and values range from 0.53 to 193.46.

  • docker_stats CPU values are used as reported. Other scopes keep the existing unit conversion.
  • Status ranks CPU against a reported container.cpu.limit. Without a CPU limit, CPU use is not a capacity signal, so status comes from memory against its limit. The measurement column then reads cpu limit not reported.
  • The panel description states that 100% is one core.

Evidence

One-hour Demo snapshot, frozen window, selected rows:

Container CPU % before → after Status before → after
load-generator 19,309.43 → 193.09 19,309.43 → 93.90 (memory, bad)
payment 1,367.69 → 13.68 1,367.69 → 48.27 (good)
frontend 1,363.74 → 13.64 1,363.74 → 51.45 (good)
otel-collector 812.37 → 8.12 812.37 → 27.56 (good)

Tests cover:

  • docker_stats percent values;
  • another scope with unit "1";
  • status with and without a CPU limit;
  • the measurement text.

Verification

  • go test ./internal/dashboard/... ./internal/panel/...: passed.
  • just check (pre-push): passed.

The Containers panel multiplied container.cpu.utilization by 100 whenever its
unit was "1". docker_stats, the receiver the panel names as its source,
already reports a percentage of one core (as docker stats does) while
declaring unit "1", so on OpenTelemetry Demo data the panel showed 19,309%
and 1,367% and marked every container bad.

- Use docker_stats CPU values as reported; keep the unit conversion for
  other scopes.
- Rank status against a reported container.cpu.limit. Without a CPU limit,
  CPU use is not a capacity signal, so status comes from memory against its
  limit, and the measurement column says the CPU limit is not reported.
- The panel description states that 100% is one core.

Claude-Session: https://claude.ai/code/session_01XA52nWyQ3R5f5kK8kjpAQW
@vishr
vishr force-pushed the fix/container-cpu branch from cefa235 to c418c96 Compare October 16, 2026 21:23
@vishr
vishr merged commit 2361b48 into main Oct 16, 2026
14 checks passed
@vishr
vishr deleted the fix/container-cpu branch October 16, 2026 21:45
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.

1 participant