in_node_exporter_metrics: add netdev ignore regex#11819
Conversation
Add netdev.ignore_device_regex so Linux network device metrics can be skipped by regular expression before metric samples are emitted. This mirrors the existing regex filtering model used by diskstats and filesystem collectors, and covers dynamic interface names such as veth0 where exact label deletion is not sufficient. Tested with: cmake -S . -B build -DFLB_CONFIG_YAML=Off -DFLB_TESTS_RUNTIME=Off -DFLB_TESTS_INTERNAL=Off -DFLB_EXAMPLES=Off cmake --build build -j8 --target flb-plugin-in_node_exporter_metrics fluent-bit-bin Also smoke-tested locally with node_exporter_metrics netdev collection and netdev.ignore_device_regex ^lo$, confirming device="lo" was absent while other network interfaces remained present. Signed-off-by: Stefano Tondo <stondo@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR extends the node exporter metrics plugin with a new optional configuration option ChangesNetwork device regex filtering in node exporter metrics
Sequence DiagramsequenceDiagram
participant Init as ne_netdev_init()
participant Helper as netdev_skip_device()
participant Update as netdev_update()
participant Exit as ne_netdev_exit()
Init->>Init: Compile regex from config text
Update->>Helper: Check if device matches regex
Helper-->>Update: Skip device flag
Update->>Update: Continue if device matched
Exit->>Exit: Destroy compiled regex
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7773cbde1e
ℹ️ 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".
| "could not initialize regex pattern for ignored " | ||
| "network devices: '%s'", | ||
| ctx->netdev_regex_skip_devices_text); | ||
| return -1; |
There was a problem hiding this comment.
Avoid arming netdev collector after regex init failure
When netdev.ignore_device_regex is syntactically invalid, this early return -1 happens after activate_collector() has already registered the netdev update callback, and in_ne_init() only logs the activation failure and continues. That leaves the timer armed without netdev_configure() initializing ctx->netdev_ht; on the next scrape netdev_hash_get() calls flb_hash_table_get() with a NULL hash table and can crash the input instead of just rejecting the bad configuration cleanly.
Useful? React with 👍 / 👎.
Summary
Add
netdev.ignore_device_regexto thenode_exporter_metricsinput so Linux network device metrics can be filtered by regular expression before samples are emitted.This mirrors the existing regex filtering model used by the diskstats and filesystem collectors, and covers dynamic interface names such as
veth0,veth1, etc. Exact label deletion after collection is not enough for this case because the interface names are runtime-generated.Example configuration
[INPUT] Name node_exporter_metrics Tag node.metrics Scrape_Interval 1 Metrics netdev netdev.ignore_device_regex ^(lo|podman|veth.*)$With this configuration,
node_network_*{device="lo"},device="podman", and dynamicdevice="veth*"series are skipped while physical or host-relevant interfaces continue to be emitted.Testing
Build verification:
cmake -S . -B build -DFLB_CONFIG_YAML=Off -DFLB_TESTS_RUNTIME=Off -DFLB_TESTS_INTERNAL=Off -DFLB_EXAMPLES=Off cmake --build build -j8 --target flb-plugin-in_node_exporter_metrics fluent-bit-binLocal runtime smoke test on Linux:
Smoke test result from
http://127.0.0.1:9927/metrics:Sample retained host interfaces:
Log excerpt from the same smoke test:
Embedded-device validation was also done with a downstream Yocto build on an ARM64 Linux device. With
netdev.ignore_device_regex: "^(lo|podman|veth.*)$":Documentation
The plugin documentation is maintained in
fluent/fluent-bit-docs. I can open a follow-up docs PR for this new option if the feature shape is accepted.Backporting
No backport requested yet. This is a small additive configuration option and should be low risk if maintainers want it on a stable branch.
Summary by CodeRabbit
netdev.ignore_device_regexconfiguration option for the node exporter metrics plugin. Users can now filter out network device metrics using regular expression patterns.