Skip to content

enhancement(host_metrics source): replace heim with sysinfo in network collector - #24818

Open
mushrowan wants to merge 1 commit into
vectordotdev:masterfrom
mushrowan:feat/host-metrics-network-sysinfo
Open

enhancement(host_metrics source): replace heim with sysinfo in network collector#24818
mushrowan wants to merge 1 commit into
vectordotdev:masterfrom
mushrowan:feat/host-metrics-network-sysinfo

Conversation

@mushrowan

@mushrowan mushrowan commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Summary

replace heim::net::io_counters() with sysinfo::Networks in the host_metrics
network collector. first step in removing the unmaintained heim dependency
(#23646). sysinfo is already a dep (used by process.rs)

network_transmit_packets_total now emitted on all platforms (was linux/windows
only). windows tx drops temporarily unavailable since sysinfo doesn't expose
drop counters yet, linux drops preserved via inline sysfs read

Vector configuration

[sources.host_metrics]
type = "host_metrics"
collectors = ["network"]

How did you test this PR?

cargo test -p vector --no-default-features --features sources-host_metrics sources::host_metrics::network

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our
    guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

@mushrowan
mushrowan requested a review from a team as a code owner March 1, 2026 11:46
@github-actions github-actions Bot added domain: sources Anything related to the Vector's sources domain: ci Anything related to Vector's CI environment labels Mar 1, 2026
@mushrowan
mushrowan force-pushed the feat/host-metrics-network-sysinfo branch from fd5bc2a to 46660f8 Compare March 1, 2026 12:08
…ollector

replace heim::net::io_counters() with sysinfo::Networks for network
metrics collection, as part of removing the unmaintained heim
dependency (vectordotdev#23646)

- sysinfo already a dep (used by process.rs), no new dependencies
- network_transmit_packets_total now emitted on all platforms
  (was linux/windows only behind heim IoCountersExt)
- tx drop counters read from sysfs on linux since sysinfo doesn't
  expose them yet (same /sys/class/net dir sysinfo reads from)
- windows tx drops temporarily unavailable, pending upstream sysinfo
- replaces async stream/filter_map chain with simple sync iteration
@mushrowan
mushrowan force-pushed the feat/host-metrics-network-sysinfo branch from 46660f8 to 3a386c6 Compare March 1, 2026 12:10
@mushrowan mushrowan changed the title refactor(host_metrics source): replace heim with sysinfo in network collector enhancement(host_metrics source): replace heim with sysinfo in network collector Mar 1, 2026
Comment on lines +76 to +83
#[cfg(target_os = "linux")]
fn read_sysfs_tx_dropped(interface: &str) -> Option<u64> {
std::fs::read_to_string(format!(
"/sys/class/net/{interface}/statistics/tx_dropped"
))
.ok()
.and_then(|s| s.trim().parse().ok())
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heim reads this directly from /proc/net/dev in Linux. We also don't want to drop windows support for network_transmit_packets_drop_total. I'd be more confident in merging this in if this were part of upstream sysinfo. Is there an upstream tracking issue for this?

Exploring an idea: is it possible to use heim to get just this one metric? We can could remove it later of course.

Comment on lines +1 to +6
The `host_metrics` source network collector now uses `sysinfo` instead of the
unmaintained `heim` crate. `network_transmit_packets_total` is now emitted on
all platforms (previously linux/windows only). Windows `network_transmit_packets_drop_total`
is temporarily unavailable pending upstream sysinfo support.

authors: mushrowan

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `host_metrics` source network collector now uses `sysinfo` instead of the
unmaintained `heim` crate. `network_transmit_packets_total` is now emitted on
all platforms (previously linux/windows only). Windows `network_transmit_packets_drop_total`
is temporarily unavailable pending upstream sysinfo support.
authors: mushrowan
The `host_metrics` source now emits `network_transmit_packets_total` on all platforms
(previously Linux and Windows only). Windows `network_transmit_packets_drop_total`
is temporarily unavailable pending upstream sysinfo support.
authors: mushrowan

@pront

pront commented Jul 27, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a386c664e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

tags,
);
}
let networks = Networks::new_with_refreshed_list();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor configured roots when collecting network counters

When host_metrics runs with PROCFS_ROOT/SYSFS_ROOT set—including the checked Kubernetes agent DaemonSet in distribution/kubernetes/vector-agent/daemonset.yaml, which mounts the host at /host/proc and /host/sysNetworks::new_with_refreshed_list() uses sysinfo's hard-coded /sys/class/net Linux backend instead. The old heim collector honored the configured PROCFS_ROOT, so this change reports the container/pod network namespace rather than the host; read_sysfs_tx_dropped also hard-codes /sys. Please preserve root-aware collection for both the main counters and dropped-packet counter.

Useful? React with 👍 / 👎.

tags,
);
}
let networks = Networks::new_with_refreshed_list();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve scrape-error telemetry for network read failures

If the OS network query fails—for example because /sys/class/net is unavailable on Linux or GetIfTable2 fails on Windows—sysinfo silently returns an empty collection, so this function emits neither metrics nor an error. The removed heim branch emitted HostMetricsScrapeDetailError, which logged the failure and incremented component_errors_total; without equivalent handling, operators cannot distinguish a broken collector from a host with no interfaces. Use a fallible collection path or otherwise detect and emit the existing internal error event.

AGENTS.md reference: AGENTS.md:L351-L353

Useful? React with 👍 / 👎.

#[cfg(windows)]
use heim::net::os::windows::IoCountersExt;
use heim::units::information::byte;
use sysinfo::Networks;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Stop enabling the unused heim network feature

A repo-wide search shows that this replacement removes the last heim::net use, but sources-host_metrics in Cargo.toml still activates heim/net. Consequently every host-metrics build continues compiling and shipping the unmaintained heim-net subcrate even though the collector now uses sysinfo, defeating this part of the dependency migration and retaining unnecessary build and third-party inventory. Remove heim/net from the feature and refresh the generated dependency artifacts.

Useful? React with 👍 / 👎.

@pront pront added the meta: awaiting author Pull requests that are awaiting their author. label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: ci Anything related to Vector's CI environment domain: sources Anything related to the Vector's sources meta: awaiting author Pull requests that are awaiting their author. source: host_metrics Anything `host_metrics` source related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants