Cluster Configuration page shows host-level CPU/memory instead of container-scoped values
Expected Behavior
When Graylog server and data nodes run in Docker, the Cluster Configuration page's CPU and memory figures should reflect each container's own usage and limits.
Current Behavior
The page shows host-level, and in one case flatly wrong, figures instead.
CPU (both node types) — host-wide, not container-scoped:
- Graylog server:
CpuLoadGaugereads OSHI'sCentralProcessor.getSystemCpuLoadTicks(), sourced from/proc/stat, a host-wide counter. - Data node:
NodeStatMetricsforwards OpenSearch'sos.cpu.percent/os.cpu.load_average.1m, which OpenSearch'sOsProbealso reads host-wide.
In a 2-node GL / 2-node DN cluster on one Docker host, all four nodes reported near-identical CPU — the host's, not each container's.
Memory (data node) — host-wide, and inflated by disk cache:
NodeStatMetrics also forwards OpenSearch's os.mem.* fields. OsProbe computes these from com.sun.management.OperatingSystemMXBean.getFreePhysicalMemorySize()/getTotalPhysicalMemorySize(), which on Linux maps to /proc/meminfo's MemFree, not
MemAvailable. MemFree excludes reclaimable page cache/buffers, which Linux — and OpenSearch/Lucene in particular — fills aggressively with disk cache. A data node with plenty of free capacity showed 98%+ memory used, driven almost entirely by page
cache the OS would instantly reclaim if needed.
This produced two concrete false signals: a data node reported 15G total memory on a 16G host (host-wide, not its container's actual limit) and recommended raising the heap; separately, both data nodes showed 98%+ memory used with no real memory pressure.
Unaffected: heap metrics (jvm.memory.heap.* on GL server, jvm.mem.heap_* on data node) are JVM-internal and correct.
Possible Solution
OpenSearch's OsProbe already detects cgroups and exposes an os.cgroup block (memory.limit_in_bytes, memory.usage_in_bytes, cpu.cfs_quota_micros, cpuacct.usage_nanos) in _nodes/stats when running under a cgroup limit. NodeStatMetrics
currently ignores this block — wiring it in would fix the data node's CPU and memory figures, including the cache-inflation problem, since cgroup memory accounting excludes reclaimable cache differently than MemFree does. The Graylog server side
needs a separate cgroup-aware CPU read, since it has no equivalent field to fall back on.
Steps to Reproduce
- Run a 2-node Graylog server + 2-node data node cluster via Docker on one host.
- Open Cluster Configuration.
- Compare the reported CPU/memory to each container's actual
docker statsor cgroup limits, and tofree -h'savailablecolumn on the host. - Note that all nodes report near-identical, host-level CPU; data node memory shows 98%+ used despite ample free/reclaimable capacity.
Context
Misleading resource figures led to an unnecessary heap-size recommendation for a data node, based on host memory rather than the container's actual limit, and a false impression of memory pressure driven by disk cache. Related to https://github.com/Graylog2/quality-assurance/issues/82 - see also there for screenshots.
Your Environment
- Graylog Version: 7.2.0-beta.1-1
- Java Version: 21
- OpenSearch Version: Data Node 7.2.0-beta-1.1
- MongoDB Version: 8.3
- Operating System: Docker on Linux
- Browser version: Firefox 154.0.1
Checklist
- [ ] This issue fix need to be backported.
- [ ] Does this issue have security implications?
Solution sounds reasonable, approx 30% of users are using containers
I'd like to work on this issue.
I've reviewed the reported behavior and the affected metric paths. The current Cluster Configuration resource metrics appear to rely on host-level OS metrics when Graylog/Data Nodes are running inside Docker, which can result in misleading CPU and memory values.
I plan to investigate the existing CpuLoadGauge and NodeStatMetrics implementations and update the containerized resource metrics to use cgroup-aware CPU and memory information where available, while preserving the existing behavior for non-containerized environments.
For Data Nodes, I'll investigate wiring the relevant cgroup metrics exposed by OpenSearch into NodeStatMetrics. For Graylog server CPU metrics, I'll investigate an appropriate cgroup-aware source rather than relying on the host-wide /proc/stat values.
I'll also add/update tests covering container/cgroup resource reporting and verify that heap metrics remain unaffected.
I'd be happy to take ownership of this issue.
Thanks for the detailed plan, @superezzdev — this is a great write-up and covers the right code paths on both the server and data node side. Go ahead and take it on!
A couple of pointers as you dig in:
- Keep the non-containerized behavior intact, as you noted — that's important since most deployments aren't in Docker.
- When you get to a PR, it'd help reviewers if you include a quick before/after comparison (e.g.
docker statsvs. the reported values) alongside your tests.
Feel free to open a draft PR early if you want feedback on direction before finishing it up. Looking forward to seeing this!
Hi @fpetersen-gl i'm working on this issue i'll have a PR soon
Hey @superezzdev, thanks for contributing! We're moving to prioritise this issue in time for the next release, so our team will be looking at it shortly. Letting you know as don't want you to waste any subsequent time and effort duplicating work that we'll do anyway.
If you can provide your PR (at whatever level of completeness) within the next few days we'll seek to include your work in the solution.
Cheers!
Hi @tellistone,
Thank you, and apologies for the delayed response. I was occupied with my university exams, so I wasn’t able to get back to you sooner. I really appreciate you following up and reminding me.
Please give me a few hours, and I’ll have a PR ready for you.
Thanks again @superezzdev for your contribution, it will be included in the Graylog 7.2 release!
Thank you @tellistone , Really appreciate it. I'm glad I could help get this fixed, and I'm looking forward to seeing it in the upcoming update.
Happy to contribute more whenever I can!