Skip to content

in_node_exporter_metrics: Add a capability to adjust log level w/ error paths#12057

Open
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-follow-up-showing-error-paths
Open

in_node_exporter_metrics: Add a capability to adjust log level w/ error paths#12057
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-follow-up-showing-error-paths

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes #12033.


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
    • Improved CPU thermal throttle metric collection on Linux by adjusting how thermal throttle counters are read for each CPU.
    • Enhanced metric file read error handling with more consistent, level-based logging to improve troubleshooting.
    • Preserved existing behavior so processing continues when an individual CPU entry can’t be read.

…or paths

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Jul 6, 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: Pro

Run ID: 22beb672-3ae7-4fdc-9bf7-9d713b4021ec

📥 Commits

Reviewing files that changed from the base of the PR and between eadc3c5 and 7325cee.

📒 Files selected for processing (1)
  • plugins/in_node_exporter_metrics/ne_utils.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/in_node_exporter_metrics/ne_utils.c

📝 Walkthrough

Walkthrough

Adds level-aware file-read helpers in ne_utils.c/ne_utils.h, centralizing failure logging with ne_utils_file_log(). Updates cpu_thermal_update in ne_cpu_linux.c to read thermal throttle counters with FLB_LOG_DEBUG.

Changes

Level-aware file read logging

Layer / File(s) Summary
API and logging helper
plugins/in_node_exporter_metrics/ne_utils.c, plugins/in_node_exporter_metrics/ne_utils.h
Adds ne_utils_file_log() to centralize file-operation failure logging, introduces ne_utils_file_read_uint64_at_level() and ne_utils_file_read_sds_at_level(), and updates the existing wrappers and declarations to use the new level-aware implementations.
CPU throttle reads
plugins/in_node_exporter_metrics/ne_cpu_linux.c
cpu_thermal_update switches the core_throttle_count and package_throttle_count reads to ne_utils_file_read_uint64_at_level(..., FLB_LOG_DEBUG).

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • fluent/fluent-bit#11839: Updates the same ne_utils file-read helpers and the cpu_thermal_update thermal throttle path with the level-aware API.

Suggested labels: backport to v4.2.x

Suggested reviewers: edsiper

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the log-level adjustment in node_exporter_metrics.
Linked Issues check ✅ Passed The change routes the thermal-throttle reads through debug-level helpers, restoring benign missing-file handling as requested in #12033.
Out of Scope Changes check ✅ Passed The refactor stays within the CPU thermal-throttle logging fix and related utility helpers, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-follow-up-showing-error-paths

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
plugins/in_node_exporter_metrics/ne_cpu_linux.c (1)

133-138: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Unconditional FLB_LOG_DEBUG also masks genuine read errors here.

This is the concrete call site affected by the uniform-downgrade concern raised in ne_utils.c: any failure reading core_throttle_count/package_throttle_count (not just an absent file) will now log at debug only, via ne_utils_file_read_uint64_at_level(..., FLB_LOG_DEBUG). See the corresponding comment in ne_utils.c for the suggested fix.

Also applies to: 155-160

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/in_node_exporter_metrics/ne_cpu_linux.c` around lines 133 - 138, The
`ne_utils_file_read_uint64_at_level()` calls in `ne_cpu_linux.c` are forcing
`FLB_LOG_DEBUG` for `core_throttle_count` and `package_throttle_count`, which
hides real read failures. Update these call sites to only downgrade the log
level for the specific expected “missing file” case, and keep genuine errors at
their normal severity. Use the existing `ne_utils_file_read_uint64_at_level`
flow and the throttle counter reads in this file to apply the same fix to both
sections.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/in_node_exporter_metrics/ne_utils.c`:
- Around line 101-112: The logging in ne_utils_file_log() and
ne_utils_file_read_uint64_at_level() is applying the caller’s debug level to
every failure, not just the expected missing-file case. Update the error
handling so ENOENT stays at the caller-supplied level, but any other errno is
logged as FLB_LOG_ERROR, preserving the path-in-message behavior without hiding
real failures. Make the same distinction wherever the helper is used, including
the cpu_thermal_update callers for core_throttle_count and
package_throttle_count.

---

Duplicate comments:
In `@plugins/in_node_exporter_metrics/ne_cpu_linux.c`:
- Around line 133-138: The `ne_utils_file_read_uint64_at_level()` calls in
`ne_cpu_linux.c` are forcing `FLB_LOG_DEBUG` for `core_throttle_count` and
`package_throttle_count`, which hides real read failures. Update these call
sites to only downgrade the log level for the specific expected “missing file”
case, and keep genuine errors at their normal severity. Use the existing
`ne_utils_file_read_uint64_at_level` flow and the throttle counter reads in this
file to apply the same fix to both sections.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e90921b6-99fb-4b3d-9093-2628bd326e94

📥 Commits

Reviewing files that changed from the base of the PR and between a1e05fc and eadc3c5.

📒 Files selected for processing (3)
  • plugins/in_node_exporter_metrics/ne_cpu_linux.c
  • plugins/in_node_exporter_metrics/ne_utils.c
  • plugins/in_node_exporter_metrics/ne_utils.h

Comment thread plugins/in_node_exporter_metrics/ne_utils.c
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
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: commit 9c1998f7c regressed the 2023 fix for missing CPU thermal-throttle counters (#7589 / #7602)

1 participant