[Monitoring] [metrics] [autoops_es] Derive cgroup CPU utilization percent in node_stats
- Dominant language
- Go
- Stars
- 12.7k
- Forks
- 5k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 370
Description
## Summary
The `autoops_es` `node_stats` metricset already collects cgroup CPU fields
(`os.cgroup.cpuacct.usage_nanos`, `os.cgroup.cpu.cfs_quota_micros`,
`os.cgroup.cpu.stat.number_of_elapsed_periods`, etc.) but does not emit a
derived CPU utilization percentage relative to the CFS quota.
## Proposal
When a previous sample exists for the node and `cfs_quota_micros > 0`, enrich
the metricset with a flat field:
`os.cgroup.cpu.usage_percent =
(Δusage_nanos / (Δnumber_of_elapsed_periods × cfs_quota_micros × 1000)) × 100`
This matches the cgroup quota utilization calculation used by Stack Monitoring
(see Kibana `QuotaMetric` / container CPU utilization docs).
## Behavior when not applicable
Do **not** set `os.cgroup.cpu.usage_percent` when:
- there is no previous sample for the node (first poll / new node)
- `cfs_quota_micros` is missing or `<= 0` (e.g. `-1` when no quota is set)
- required counter fields are missing or deltas are not usable
Consumers can keep using `process.cpu.percent` when the derived field is absent.
## Implementation notes
- Add enrichment next to existing `node_stats` rate/latency enrichers that already
use the per-node previous-sample cache.
- Unit tests for: positive quota, `cfs_quota_micros == -1`, first sample, zero deltas.
Contributor guide
Assessment
This issue has not been assessed yet.