Always use the local filesystem for self-monitoring metrics#282
Always use the local filesystem for self-monitoring metrics#282belimawr merged 11 commits intoelastic:mainfrom
Conversation
28fadb2 to
6378f81
Compare
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
|
one last question. the |
Yes, that's my understanding. Also everything there collect metrics only for the process own PID. |
Yeah, that risk crossed my mind, but the changes only force the metrics to be collected from the root filesystem, which works in any environment. The existing tests are passing, and I even added a new one that sets the env vars like Metricbeat to an nonexistent path to ensure we never use it. So I'm pretty confident that this won't break anything else. |
yeah, I checked the |
What does this PR do?
Always use the local filesystem for self-monitoring metrics.
Metricbeat will use the hostfs to set the environment variables:
which are read by github.com/shirou/gopsutil/v4 and used when fetching metrics. However, the hostfs is not available by the time self monitoring metrics are initialised, so when running in a container environment, we cannot resolve the PID relative to the hostfs PID namespace.
This causes
elastic-agent-system-metricsto get the PID usingos.Getpid, andgopsutiluses the hostfs to fetch all metrics, causing us to get metrics from the wrong process or getting an error because/hostfs/proc/<PID>/fddoes not exist.Always using the local filesystem for self-monitoring metrics solves this problem.
Why is it important?
It allows a Beat to correctly get metrics from its own process.
Checklist
## Author's ChecklistRelated issues