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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds an optional 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 device name against compiled regex
Helper-->>Update: Return skip=true/false
Update->>Update: Continue (skip) if matched
Exit->>Exit: Destroy compiled regex
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)plugins/in_node_exporter_metrics/ne.cplugins/in_node_exporter_metrics/ne.c:20:10: fatal error: 'fluent-bit/flb_input_plugin.h' file not found ... [truncated 767 characters] ... 6_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include" 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 👍 / 👎.
|
I checked the init/error path more closely and the concern was valid: I pushed a follow-up fix in:
That change removes the already-registered collector and resets Please take another look. |
4920043 to
53917e6
Compare
Signed-off-by: Stefano Tondo <stondo@gmail.com>
53917e6 to
c67cfed
Compare
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
New Features
Bug Fixes