Skip to content

Conversation

@edsiper
Copy link
Member

@edsiper edsiper commented Aug 11, 2025

This PR fixes #10650

This PR introduces a new path.rootfs configuration parameter to the node_exporter_metrics input plugin, simplifying containerized deployments by allowing users to specify a single root filesystem mount point instead of mounting /proc and /sys separately.

Changes Made

Plugin Configuration:

  • Added path.rootfs config option with default value /
  • When path.rootfs is set to a non-root path, the plugin automatically composes full paths for:

e.g:

  • path.procfs → {rootfs}/proc
  • path.sysfs → {rootfs}/sys
  • path.textfile → {rootfs}/{textfile_path} (if specified)

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

  • New Features
    • Added a rootfs path configuration for Node Exporter Metrics, automatically prefixing procfs/sysfs/textfile paths to simplify containerized setups.
  • Documentation
    • Added comments guiding how to use host root paths when running in containers.
  • Chores
    • Updated the node-exporter dashboard container to mount the host root as read-only and use the new rootfs configuration, reducing multiple bind mounts to a single one.
  • Bug Fixes
    • Improved error logging when reading system stats fails, aiding troubleshooting.

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Walkthrough

Introduces path.rootfs support to the in_node_exporter_metrics plugin, adds rootfs-based path composition for procfs/sysfs/textfile, updates docker-compose to use path.rootfs with a host root mount, adds a minor error log, and inserts non-functional comments and formatting changes.

Changes

Cohort / File(s) Summary
Config comments
conf/fluent-bit-metrics.conf
Added two comments explaining host root path usage; no runtime effect.
Docker compose update
docker_compose/node-exporter-dashboard/docker-compose.yml
Switched Fluent Bit args from path.procfs/path.sysfs to path.rootfs; changed mounts from /proc and /sys to read-only host root (/:/host:ro).
Plugin config map: path.rootfs
plugins/in_node_exporter_metrics/ne.c
Added config_map entry for path.rootfs (string, default “/”) mapped to flb_ne.path_rootfs.
Plugin context struct
plugins/in_node_exporter_metrics/ne.h
Added flb_sds_t path_rootfs to struct flb_ne.
Rootfs path composition logic
plugins/in_node_exporter_metrics/ne_config.c
On init, prefixes procfs/sysfs/textfile paths with path.rootfs (handling trailing slash); logs selected paths.
Linux stat logging
plugins/in_node_exporter_metrics/ne_stat_linux.c
Added error log when reading procfs stat fails.
Formatting only
plugins/in_node_exporter_metrics/ne_utils.c, plugins/in_node_exporter_metrics/ne_utils.h
Reflowed function declaration formatting; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FluentBit
    participant in_node_exporter_metrics
    participant HostFS

    User->>FluentBit: Configure path.rootfs=/host
    FluentBit->>in_node_exporter_metrics: Initialize plugin
    in_node_exporter_metrics->>in_node_exporter_metrics: Compose procfs/sysfs/textfile paths with path.rootfs
    in_node_exporter_metrics->>HostFS: Read /host/proc, /host/sys, textfiles
    HostFS-->>in_node_exporter_metrics: Metrics data
    in_node_exporter_metrics-->>FluentBit: Emit metrics
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Add path.rootfs configuration to in_node_exporter_metrics (#10650)
Use path.rootfs to prefix filesystem access for metrics collection (#10650)

Possibly related PRs

Suggested labels

docs-required

Suggested reviewers

  • leonardo-albertovich
  • koleini
  • fujimotos

Poem

I hop through roots where syscalls grow,
A burrow mapped to /host below.
With whiskered logs and paths anew,
I sniff out metrics, crisp and true.
One leap, proc sings; two hops, sys gleams—
Rootfs aligned, we harvest streams. 🐇📊


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7aba68 and f2e24ca.

📒 Files selected for processing (8)
  • conf/fluent-bit-metrics.conf (1 hunks)
  • docker_compose/node-exporter-dashboard/docker-compose.yml (1 hunks)
  • plugins/in_node_exporter_metrics/ne.c (1 hunks)
  • plugins/in_node_exporter_metrics/ne.h (1 hunks)
  • plugins/in_node_exporter_metrics/ne_config.c (2 hunks)
  • plugins/in_node_exporter_metrics/ne_stat_linux.c (1 hunks)
  • plugins/in_node_exporter_metrics/ne_utils.c (1 hunks)
  • plugins/in_node_exporter_metrics/ne_utils.h (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
plugins/in_node_exporter_metrics/ne_config.c (1)
src/flb_sds.c (2)
  • flb_sds_create_size (92-95)
  • flb_sds_printf (336-387)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: pr-windows-build / call-build-windows-package (Windows 32bit, x86, x86-windows-static, 3.31.6)
  • GitHub Check: PR - fuzzing test
  • GitHub Check: pr-compile-centos-7
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=Off, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_THREAD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SANITIZE_MEMORY=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SIMD=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_UNDEFINED=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DSANITIZE_ADDRESS=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_SMALL=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, gcc, g++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=On, 3.31.6, clang, clang++)
  • GitHub Check: run-ubuntu-unit-tests (-DFLB_JEMALLOC=Off, 3.31.6, gcc, g++)
  • GitHub Check: PR - Buildkit docker build test
  • GitHub Check: PR - Classic docker build test
  • GitHub Check: PR - Docker windows build test, windows 2022 and 2025 (2022)
  • GitHub Check: PR - Docker windows build test, windows 2022 and 2025 (2025)
🔇 Additional comments (8)
plugins/in_node_exporter_metrics/ne_utils.h (1)

38-39: LGTM! Formatting improvement.

The parameter line-wrapping improves readability without changing the function signature.

plugins/in_node_exporter_metrics/ne_utils.c (1)

199-201: LGTM! Consistent formatting.

The parameter formatting is now consistent with the header file and improves readability.

plugins/in_node_exporter_metrics/ne_stat_linux.c (1)

88-88: Good improvement for debugging.

Adding error logging when stat file reading fails will help with troubleshooting, especially now that path_procfs can be dynamically composed with rootfs prefix.

conf/fluent-bit-metrics.conf (1)

18-19: Helpful documentation addition.

These comments provide clear guidance on using the new path.rootfs feature for containerized deployments.

plugins/in_node_exporter_metrics/ne.h (1)

51-51: Well-structured field addition.

The path_rootfs field is appropriately typed and positioned within the configuration section of the struct.

plugins/in_node_exporter_metrics/ne.c (1)

436-440: Well-implemented configuration option.

The path.rootfs configuration entry follows established patterns with appropriate default value and clear description.

docker_compose/node-exporter-dashboard/docker-compose.yml (2)

7-7: Correct configuration for rootfs usage.

The command properly demonstrates the new rootfs functionality by using a single path.rootfs parameter instead of separate procfs/sysfs parameters.


13-13: Good security practice with simplified mount.

The single host root mount with read-only flag simplifies the configuration while maintaining security. This aligns perfectly with the new rootfs feature.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch in_node_exporter_metrics-rootfs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

in_node_exporter_metrics: add support of path.rootfs configuration

2 participants