Skip to content

in_node_exporter_metrics: expire metrics for networking - #12372

Merged
edsiper merged 2 commits into
masterfrom
cosmo0920-expire-metrics-for-networking
Sep 4, 2026
Merged

in_node_exporter_metrics: expire metrics for networking#12372
edsiper merged 2 commits into
masterfrom
cosmo0920-expire-metrics-for-networking

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This is because network interfaces sometimes absent after VM creation and exit.

The test is now implemented in the existing runtime binary at in_node_exporter_metrics.c and registered at line 314.

Summary:

  • Creates a fake /proc/net/dev containing eth0 and veth-stale.
  • Confirms both are emitted.
  • Rewrites the file without veth-stale.
  • Confirms the next snapshot retains eth0 but removes veth-stale.

The existing diskstats test was restored in the same binary. The netdev test is Linux-only, so macOS correctly reports one test; Linux will report two. The CMake registration now supports the binary on both platforms at CMakeLists.txt

Verification:

  • cmake --build build --target flb-rt-in_node_exporter_metrics -j8 — passed.
  • ctest --test-dir build -R '^flb-rt-in_node_exporter_metrics$' --output-on-failure — passed on macOS (diskstats).
  • Linux netdev execution and memory-checker pass — not run because this host is macOS; the Linux-only section passed a forced syntax compilation.

Closes #9400.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes

    • Network device metrics now remove stale label sets when devices are no longer detected, preventing outdated device metrics from persisting across scans.
  • Tests

    • Added runtime coverage for disk statistics metric collection.
    • Added Linux coverage verifying that metrics for removed network devices disappear from subsequent snapshots.

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T07:50:13.613737Z a41394d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 97953410-1cc7-49ad-9488-e4b4cc49b8c1

📥 Commits

Reviewing files that changed from the base of the PR and between 98f3bde and a41394d.

📒 Files selected for processing (4)
  • plugins/in_node_exporter_metrics/ne_netdev_darwin.c
  • plugins/in_node_exporter_metrics/ne_netdev_linux.c
  • tests/runtime/CMakeLists.txt
  • tests/runtime/in_node_exporter_metrics.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The netdev collectors now expire labels for devices absent from a scan. Runtime coverage adds diskstats output validation and a Linux test for stale network-device removal.

Changes

Network metric expiration

Layer / File(s) Summary
Collector metric expiration
plugins/in_node_exporter_metrics/ne_netdev_linux.c, plugins/in_node_exporter_metrics/ne_netdev_darwin.c
The Linux and Darwin collectors expire metric label sets for devices not observed during the current scan.
Runtime test harness
tests/runtime/in_node_exporter_metrics.c, tests/runtime/CMakeLists.txt
Runtime output handling, the diskstats scrape test, platform registration, and test-list entries were added.
Stale device validation
tests/runtime/in_node_exporter_metrics.c
A Linux test uses temporary procfs data to verify that a removed network device disappears from later metric snapshots.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a4139

This change removes metrics for network interfaces that disappear between scans and adds runtime coverage for the expected lifecycle. No merge-blocking risk is currently identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: expiring stale network metrics in the node exporter metrics plugin. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-expire-metrics-for-networking

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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

# Input Plugins
FLB_RT_TEST(FLB_IN_EVENT_TEST "in_event_test.c")
# FLB_IN_WINEVTLOG is only enabled on Windows builds

P1 Badge Split the runtime tests into a separate commit

This commit combines the node-exporter plugin implementation with a new runtime test and its CMake registration, while the repository requires plugin changes and tests to be separate commits. Move this registration and in_node_exporter_metrics.c into a tests: runtime: commit, leaving the plugin changes in the component commit.

AGENTS.md reference: AGENTS.md:L174-L179

ℹ️ 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".

Comment thread plugins/in_node_exporter_metrics/ne_netdev_linux.c
Comment thread plugins/in_node_exporter_metrics/ne_netdev_linux.c
@edsiper
edsiper merged commit a51fc60 into master Sep 4, 2026
110 of 116 checks passed
@edsiper edsiper added this to the Fluent Bit v5.1.2 milestone Sep 4, 2026
@edsiper
edsiper deleted the cosmo0920-expire-metrics-for-networking branch September 4, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node_metrics output plugin producing stale data for no longer existent network devices

2 participants