feat(host_metrics): expose number of oom_kill events#25802
Conversation
776a10b to
39584c3
Compare
| use crate::internal_events::HostMetricsScrapeDetailError; | ||
|
|
||
| #[cfg(target_os = "linux")] | ||
| const OOM_KILL: &str = "oom_kill"; |
There was a problem hiding this comment.
I was a bit unsure regarding the naming of this metric.
Should this be called memory_oom_kill_events? Or oom_kill_events?
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 776a10b2ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| output.name = "memory"; | ||
|
|
||
| // Spawn blocking task to avoid blocking the async runtime with synchronous I/O | ||
| let result = tokio::task::spawn_blocking(procfs::vmstat) |
There was a problem hiding this comment.
When host_metrics is run with the documented PROCFS_ROOT override (for example a container mounting the host proc tree under /host/proc or tests using a fixture), this calls procfs::vmstat, which reads the process' default /proc/vmstat; init_roots only configures heim, so the new memory metric ignores the configured proc root while the existing memory metrics honor it. This can report OOM kills from the wrong proc tree or fail even though the configured proc root is valid, so read vmstat through the configured procfs root instead of the crate default.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
As far as I'm aware, /proc/vmstat is not cgroup-aware and therefore returns the values from the host.
In addition, the procfs crate does not support customization of the procfs root iirc.
| match result { | ||
| Ok(stats) => { | ||
| if let Some(&oom_kill) = stats.get("oom_kill") { | ||
| output.counter(OOM_KILL, oom_kill as f64, MetricTags::default()); |
There was a problem hiding this comment.
Use a total-suffixed counter name
This emits a public counter named oom_kill, but Vector's metric naming spec requires counters to end in _total, and the other host memory counters follow that pattern (memory_swapped_in_bytes_total, memory_swapped_out_bytes_total). Shipping the new metric without the suffix makes the API non-compliant and any later rename would be breaking for users, so use a total-suffixed counter name and update the docs/tests together.
Useful? React with 👍 / 👎.
Summary
This PR adds the
oom_killmetric to thehost_metricssource.The metric is read from
procfs, which is already a dependency.Vector configuration
Config
How did you test this PR?
Manual test with the configuration outlined above.
Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.