Skip to content

docs: outputs: file: add log rotation support and configuration examples#2572

Open
SagiROosto wants to merge 1 commit into
fluent:masterfrom
SagiROosto:aws-iot-creds-docs
Open

docs: outputs: file: add log rotation support and configuration examples#2572
SagiROosto wants to merge 1 commit into
fluent:masterfrom
SagiROosto:aws-iot-creds-docs

Conversation

@SagiROosto
Copy link
Copy Markdown

@SagiROosto SagiROosto commented May 12, 2026

This is the docs PR for fluent/fluent-bit#11352 about out_file logrotate feature

Summary by CodeRabbit

  • Documentation
    • Added docs for size-based log rotation for file outputs via a new files_rotation option, describing gzip compression, max_files retention, and max_size thresholds; includes a “Log rotation” section covering timestamped rotated filenames, optional .gz compression, retention behavior, thread-safe operation with multiple workers, supported output formats, and YAML/Fluent Bit CONF examples.

Review Change Stack

@SagiROosto SagiROosto requested review from a team and eschabell as code owners May 12, 2026 10:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

Documentation for the File output plugin adds log rotation details: new parameters (files_rotation, gzip, max_files, max_size) in the parameter table and a "Log rotation" section explaining rotation naming, compression, retention, thread-safety, and example configurations.

Changes

File Output Plugin Log Rotation Documentation

Layer / File(s) Summary
Rotation parameter reference
pipeline/outputs/file.md
Parameter table updated with four log rotation configuration options: files_rotation (enable rotation), gzip (compress rotated files), max_files (retention count), and max_size (rotation threshold with size suffixes like 5M, 1G).
Log rotation feature documentation
pipeline/outputs/file.md
New "Log rotation" section describes how rotation is triggered by size, how rotated files are named with timestamps, how gzip compression and retention limits work, notes on thread-safe rotation with workers, compatibility with all output formats, and complete YAML and Fluent Bit config syntax examples.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

5.0.5

Suggested reviewers

  • patrick-stephens

Poem

🐰 I hopped through docs to spin a thread,
Of files that roll when they've grown and sped,
Gzip hugs old tails, numbers fade away,
Max files keep the meadow tidy each day,
A tiny rabbit cheers the plugin's play.

🚥 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 and specifically describes the main change: adding documentation for log rotation support and configuration examples to the file output plugin documentation.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 `@pipeline/outputs/file.md`:
- Line 123: Update the documentation string that describes the rotation filename
pattern used when files_rotation is enabled: replace the incorrect timestamp
token `YYYMMDD_HHMMSS` with the correct `YYYYMMDD_HHMMSS` in the sentence that
explains how files are renamed (the block referencing `files_rotation` and
`max_size` and the pattern `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`).
🪄 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: fff268df-ab55-483a-afc7-89cb4c1a696a

📥 Commits

Reviewing files that changed from the base of the PR and between 9d4bab9 and 713685c.

📒 Files selected for processing (1)
  • pipeline/outputs/file.md

Comment thread pipeline/outputs/file.md Outdated
@SagiROosto SagiROosto force-pushed the aws-iot-creds-docs branch from 2fc7093 to 3f1a696 Compare May 12, 2026 10:53
@eschabell
Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Collaborator

@eschabell eschabell left a comment

Choose a reason for hiding this comment

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

@SagiROosto see changes to be made first before review passes.

Comment thread pipeline/outputs/file.md Outdated

The plugin retains up to `max_files` rotated files per output file. When the limit is reached, the oldest rotated files are deleted automatically.

Log rotation works with all supported output [formats](#format), including `out_file`, plain, CSV, LTSV, template, and msgpack. File operations are thread-safe, so rotation can be used alongside multiple [workers](../../administration/multithreading.md#outputs).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SagiROosto can you put back-ticks around all the formats listed here:

  • plain
  • CSV
  • LTSV
  • template
  • msgpack.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pipeline/outputs/file.md (1)

123-123: ⚡ Quick win

Improve grammar and consistency for the timestamp description.

The phrase "The YYYYMMDD_HHMMSS is timestamp of the time when the rotation occurred" is missing an article and should use backticks for consistency with other technical terms in the sentence.

📝 Suggested improvement
-When `files_rotation` is enabled, the plugin monitors the size of each output file. Once a file exceeds `max_size`, the plugin rotates the file by renaming it with a timestamp suffix in the format `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`. The YYYYMMDD_HHMMSS is timestamp of the time when the rotation occurred, and `XXXXXXXX` is a random identifier to guarantee unique filenames if multiple rotations happen within the same second.
+When `files_rotation` is enabled, the plugin monitors the size of each output file. Once a file exceeds `max_size`, the plugin rotates the file by renaming it with a timestamp suffix in the format `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`. The `YYYYMMDD_HHMMSS` part is the rotation timestamp, and `XXXXXXXX` is a random identifier to guarantee unique filenames if multiple rotations happen within the same second.
🤖 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 `@pipeline/outputs/file.md` at line 123, The sentence describing the rotation
timestamp is missing an article and inconsistent formatting; update the text
that explains the rotation suffix `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`
(referencing `files_rotation` and `max_size`) to say: "The `YYYYMMDD_HHMMSS` is
the timestamp of the time when the rotation occurred" (use backticks around
`YYYYMMDD_HHMMSS` and `XXXXXXXX` for consistency) and ensure the full format is
shown as `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>` with `XXXXXXXX` described as a
random identifier to guarantee unique filenames if multiple rotations happen
within the same second.
🤖 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.

Nitpick comments:
In `@pipeline/outputs/file.md`:
- Line 123: The sentence describing the rotation timestamp is missing an article
and inconsistent formatting; update the text that explains the rotation suffix
`<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>` (referencing `files_rotation` and
`max_size`) to say: "The `YYYYMMDD_HHMMSS` is the timestamp of the time when the
rotation occurred" (use backticks around `YYYYMMDD_HHMMSS` and `XXXXXXXX` for
consistency) and ensure the full format is shown as
`<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>` with `XXXXXXXX` described as a random
identifier to guarantee unique filenames if multiple rotations happen within the
same second.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5451bf1e-296d-4c22-8cd4-392c91258065

📥 Commits

Reviewing files that changed from the base of the PR and between 713685c and 3f1a696.

📒 Files selected for processing (1)
  • pipeline/outputs/file.md

Comment thread pipeline/outputs/file.md Outdated

The File output plugin supports size-based log rotation.

When `files_rotation` is enabled, the plugin monitors the size of each output file. Once a file exceeds `max_size`, the plugin rotates the file by renaming it with a timestamp suffix in the format `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`. The YYYYMMDD_HHMMSS is timestamp of the time when the rotation occurred, and `XXXXXXXX` is a random identifier to guarantee unique filenames if multiple rotations happen within the same second.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SagiROosto also add back-ticks to the "YYYYMMDD_HHMMSS" for consistency.

@eschabell eschabell self-assigned this May 12, 2026
@eschabell eschabell added waiting-for-user Waiting for user/contributors feedback or requested changes waiting-on-code-merge waiting-on-review Waiting on a review from mainteners labels May 12, 2026
@SagiROosto SagiROosto force-pushed the aws-iot-creds-docs branch from 3f1a696 to 63477a5 Compare May 12, 2026 12:32
Copy link
Copy Markdown
Contributor

@patrick-stephens patrick-stephens left a comment

Choose a reason for hiding this comment

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

Some queries around bad-path behaviours but nothing blocking, it would be nice to resolve them though for the inevitable failures that people will have.

Comment thread pipeline/outputs/file.md
Comment thread pipeline/outputs/file.md
Comment thread pipeline/outputs/file.md Outdated

The File output plugin supports size-based log rotation.

When `files_rotation` is enabled, the plugin monitors the size of each output file. Once a file exceeds `max_size`, the plugin rotates the file by renaming it with a timestamp suffix in the format `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`. The `YYYYMMDD_HHMMSS` is timestamp of the time when the rotation occurred, and `XXXXXXXX` is a random identifier to guarantee unique filenames if multiple rotations happen within the same second.
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.

Where does the timestamp come from? Is it UTC or local timezone based?

Be nice to have a controllable format for the future too.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SagiROosto can you answer this for @patrick-stephens ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The suffix uses local wall-clock time, not UTC: time(NULL) → localtime_r() → strftime(..., "%Y%m%d_%H%M%S", ...), then _ plus 8 lowercase hex digits from flb_random_bytes() (fallback if RNG fails) so multiple rotations in the same second don’t collide.

Example: cpu.log.20260512_134500_a1b2c3d4 (and .gz when gzip is enabled).

There is no configurable timestamp format in the current implementation—fixed YYYYMMDD_HHMMSS + random tail. Agree a future option (e.g. UTC vs local, strftime template) would be useful; happy to track as a follow-up if we want it called out in the docs “limitations” section.

Copy link
Copy Markdown
Collaborator

@eschabell eschabell left a comment

Choose a reason for hiding this comment

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

@SagiROosto can you answer the tagged questions for @patrick-stephens ?

Comment thread pipeline/outputs/file.md
Comment thread pipeline/outputs/file.md
Comment thread pipeline/outputs/file.md Outdated

The File output plugin supports size-based log rotation.

When `files_rotation` is enabled, the plugin monitors the size of each output file. Once a file exceeds `max_size`, the plugin rotates the file by renaming it with a timestamp suffix in the format `<filename>.<YYYYMMDD_HHMMSS_XXXXXXXX>`. The `YYYYMMDD_HHMMSS` is timestamp of the time when the rotation occurred, and `XXXXXXXX` is a random identifier to guarantee unique filenames if multiple rotations happen within the same second.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SagiROosto can you answer this for @patrick-stephens ?

@SagiROosto
Copy link
Copy Markdown
Author

Done, see my replies. @eschabell @patrick-stephens

@patrick-stephens
Copy link
Copy Markdown
Contributor

Can we capture the clarifications in the actual docs as I know at least some of those questions will likely come up and better than tracking down this PR?

@SagiROosto SagiROosto closed this May 24, 2026
@SagiROosto SagiROosto deleted the aws-iot-creds-docs branch May 24, 2026 08:34
@SagiROosto SagiROosto restored the aws-iot-creds-docs branch May 24, 2026 08:34
@SagiROosto SagiROosto reopened this May 24, 2026
Signed-off-by: SagiROosto <sagi.rosenthal@oosto.com>
@SagiROosto SagiROosto force-pushed the aws-iot-creds-docs branch from 63477a5 to ed1836f Compare May 24, 2026 09:05
@SagiROosto
Copy link
Copy Markdown
Author

@patrick-stephens I've added a ## Log rotation section that should answer all these questions.
let me know if additional clarifications needed

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pipeline/outputs/file.md (2)

123-124: ⚡ Quick win

Add clarification about flush-driven rotation behavior.

In the PR discussion, you explained that rotation is flush-driven (size check occurs at the start of each flush, not periodically), and @patrick-stephens requested this be captured in the documentation. Consider adding a sentence clarifying that the size check happens when Fluent Bit is about to write new data to the file, and that the active file may temporarily exceed max_size until the next flush triggers rotation.

For example: "The size check occurs before each flush operation. The active file may temporarily exceed max_size between flushes, but will be rotated before the next chunk is written."

Based on learnings, this clarification addresses a reviewer's explicit request to document the flush-driven rotation behavior explained in the PR discussion.

🤖 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 `@pipeline/outputs/file.md` around lines 123 - 124, Add a short clarifying
sentence about flush-driven rotation to the documentation near
files_rotation/max_size: state that the size check is performed at the start of
each flush (when Fluent Bit is about to write a new chunk), so the active file
can temporarily exceed max_size between flushes but will be rotated before the
next write; update the paragraph that describes the timestamped rename behavior
to include this flush-driven detail and use the terms "flush", "files_rotation",
and "max_size" so it's discoverable.

17-18: ⚡ Quick win

Consider documenting configuration validation behavior.

Based on the PR discussion, invalid max_files values (<= 0) cause startup failures, and invalid max_size strings may not be rejected but result in rotation never triggering. Adding a brief note about validation behavior would help users troubleshoot configuration errors.

For example, you could add a sentence to the max_files description: "If set to 0 or negative, Fluent Bit will fail to start."

🤖 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 `@pipeline/outputs/file.md` around lines 17 - 18, Update the descriptions for
the `max_files` and `max_size` configuration entries (both under
`files_rotation`) to document validation behavior: for `max_files` add a
sentence such as "If set to 0 or negative, Fluent Bit will fail to start." for
`max_size` add a sentence noting accepted suffixes (`k`, `m`, `g`) and that
malformed values may be ignored causing rotation to never trigger; keep both
notes scoped with the existing "Only applies when `files_rotation` is enabled"
wording so users know when validation applies.
🤖 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.

Nitpick comments:
In `@pipeline/outputs/file.md`:
- Around line 123-124: Add a short clarifying sentence about flush-driven
rotation to the documentation near files_rotation/max_size: state that the size
check is performed at the start of each flush (when Fluent Bit is about to write
a new chunk), so the active file can temporarily exceed max_size between flushes
but will be rotated before the next write; update the paragraph that describes
the timestamped rename behavior to include this flush-driven detail and use the
terms "flush", "files_rotation", and "max_size" so it's discoverable.
- Around line 17-18: Update the descriptions for the `max_files` and `max_size`
configuration entries (both under `files_rotation`) to document validation
behavior: for `max_files` add a sentence such as "If set to 0 or negative,
Fluent Bit will fail to start." for `max_size` add a sentence noting accepted
suffixes (`k`, `m`, `g`) and that malformed values may be ignored causing
rotation to never trigger; keep both notes scoped with the existing "Only
applies when `files_rotation` is enabled" wording so users know when validation
applies.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 932fe614-e3d9-4a25-ad82-4de417179c21

📥 Commits

Reviewing files that changed from the base of the PR and between 63477a5 and ed1836f.

📒 Files selected for processing (1)
  • pipeline/outputs/file.md

@eschabell eschabell self-requested a review May 26, 2026 05:56
Copy link
Copy Markdown
Collaborator

@eschabell eschabell left a comment

Choose a reason for hiding this comment

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

@SagiROosto thanks for the updates, good to go now once the code PR merges.

@eschabell eschabell removed waiting-for-user Waiting for user/contributors feedback or requested changes waiting-on-review Waiting on a review from mainteners labels May 26, 2026
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.

3 participants