Skip to content

in_process_exporter_metrics: Fix the reported RSS ram#12139

Open
anagno wants to merge 1 commit into
fluent:masterfrom
anagno:fix/process_plugin
Open

in_process_exporter_metrics: Fix the reported RSS ram#12139
anagno wants to merge 1 commit into
fluent:masterfrom
anagno:fix/process_plugin

Conversation

@anagno

@anagno anagno commented Jul 22, 2026

Copy link
Copy Markdown

The RSS value exported through process_memory_bytes was taken directly from /proc/pid/stat, which is reported in pages rather than bytes.

So before exposing the metric we have to convert to bytes, by using the size of pages

I tested it with my devices and now the results match the ones from htop


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:

  • [N/A] Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • [N/A] 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.

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

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] 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
    • Corrected process memory RSS metrics so values are accurately converted from system memory pages to bytes.
    • Added safeguards for environments where the system page size cannot be determined, improving metric reliability.
    • Virtual memory metrics remain unchanged.

The RSS value exported through process_memory_bytes was taken directly
from /proc/<pid>/stat, which is reported in pages rather than bytes.

So before exposing the metric we have to convert to bytes, by using
the size of pages

Signed-off-by: Vasileios Anagnostopoulos <anagnwstopoulos@hotmail.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The process exporter now caches the system page size during configuration and uses it to convert procfs RSS page counts to bytes when collecting memory metrics.

Changes

Process exporter memory metrics

Layer / File(s) Summary
Page-size initialization
plugins/in_process_exporter_metrics/pe.h, plugins/in_process_exporter_metrics/pe_config.c
Adds page_size to flb_pe and initializes it with sysconf(_SC_PAGESIZE).
RSS pages-to-bytes conversion
plugins/in_process_exporter_metrics/pe_process.c
Multiplies RSS pages by the cached page size when the page size is positive; virtual memory handling remains unchanged.

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

Suggested reviewers: cosmo0920

🚥 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 clearly matches the main change: correcting RSS memory reporting in in_process_exporter_metrics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

🤖 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_process_exporter_metrics/pe_config.c`:
- Around line 43-45: Update the page-size initialization in the pe_config setup
to detect when sysconf(_SC_PAGESIZE) returns a non-positive value, then emit a
warning or apply an explicit fallback before RSS conversion proceeds. Preserve
the existing page_size value and downstream RSS-skipping behavior when the
lookup fails.
🪄 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: 6b5a0f53-cfe2-4dba-8d7f-3b66d43f0c21

📥 Commits

Reviewing files that changed from the base of the PR and between c830fb6 and ee657f2.

📒 Files selected for processing (3)
  • plugins/in_process_exporter_metrics/pe.h
  • plugins/in_process_exporter_metrics/pe_config.c
  • plugins/in_process_exporter_metrics/pe_process.c

Comment thread plugins/in_process_exporter_metrics/pe_config.c

@cosmo0920 cosmo0920 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks for the fix.

@anagno

anagno commented Jul 23, 2026

Copy link
Copy Markdown
Author

@cosmo0920 Am I the reason for the failing test or is it flaky?

@cosmo0920

Copy link
Copy Markdown
Contributor

@cosmo0920 Am I the reason for the failing test or is it flaky?

The failing test is one of the flaky tests. So, it's okey to merge.

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.

2 participants