Skip to content

docs: env: bash-style default value operator :-#2568

Open
benjaminmueggenburg-serato wants to merge 1 commit into
fluent:masterfrom
benjaminmueggenburg-serato:master
Open

docs: env: bash-style default value operator :-#2568
benjaminmueggenburg-serato wants to merge 1 commit into
fluent:masterfrom
benjaminmueggenburg-serato:master

Conversation

@benjaminmueggenburg-serato
Copy link
Copy Markdown

@benjaminmueggenburg-serato benjaminmueggenburg-serato commented May 8, 2026

Waiting on code merge: fluent/fluent-bit#11787

Updates documentation to mention the default value operator i.e ${ENV_VAR:-default}. Feature applies to both legacy config and YAML config files.

Has some examples, and details the expected behaviour.

Summary by CodeRabbit

  • Documentation
    • Clarified environment-variable substitution syntax for Fluent Bit configuration, including standard and default-value forms.
    • Added a “Fallback behavior”/“Default values” explanation showing that defaults apply when variables are unset or empty.
    • Included practical examples demonstrating how configuration fields fall back to provided default values.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

📝 Walkthrough

Walkthrough

This PR updates Fluent Bit documentation to clarify environment variable substitution. Two files are enhanced with explicit syntax documentation for standard variable references and default-value fallback syntax, alongside a new subsection explaining when defaults apply.

Changes

Environment Variable Substitution Documentation

Layer / File(s) Summary
Variable Substitution Syntax
administration/configuring-fluent-bit/classic-mode/variables.md, administration/configuring-fluent-bit/yaml/environment-variables-section.md
Documents both ${MY_VARIABLE} and ${MY_VARIABLE:-default_value} syntax formats. Classic-mode section explicitly defines supported interpolation forms; YAML section adds "Default values" section with example of service.flush defaulting to 5 when FLUSH_INTERVAL is unset.
Fallback Behavior & Implementation Details
administration/configuring-fluent-bit/classic-mode/variables.md
Introduces "Fallback behavior" subsection specifying that ${VARIABLE:-DEFAULT} resolves to DEFAULT when variable is unset or an empty string; restructures previous example into a formal list.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit nibbles lines with care,

Variables now state what's fair.
Defaults step in when values flee,
Docs now clear as carrot tea,
Hoppy reads for you and me!

🚥 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 identifies the main change: documentation updates for the bash-style default value operator syntax in environment variables.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

🧹 Nitpick comments (2)
administration/configuring-fluent-bit/classic-mode/variables.md (2)

22-26: 💤 Low value

Minor terminology clarification.

The phrase "primary variable" at line 23 could be simplified to just "the variable" for clarity. The word "primary" doesn't add meaningful distinction here since there's only one variable being evaluated.

📝 Proposed simplification
-If the `${VARIABLE:-DEFAULT}` syntax is used, Fluent Bit will use the `DEFAULT` value if the primary variable meets either of the following conditions:
+If the `${VARIABLE:-DEFAULT}` syntax is used, Fluent Bit will use the `DEFAULT` value if the variable meets either of the following conditions:
🤖 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 `@administration/configuring-fluent-bit/classic-mode/variables.md` around lines
22 - 26, Replace the phrase "primary variable" with "the variable" in the
"Fallback Behavior" section describing the `${VARIABLE:-DEFAULT}` syntax so the
bullet points read that Fluent Bit will use the `DEFAULT` value if the variable
is not defined (unset) or is defined but set to an empty string; update the
sentence containing "primary variable" under the "Fallback Behavior" heading to
use "the variable" for clarity.

17-17: 💤 Low value

Grammar: Use hyphen to join compound modifier.

"Debian based system" should be "Debian-based system" when used as a compound adjective before a noun.

📝 Proposed fix
-- `/etc/default/fluent-bit` (Debian based system)
+- `/etc/default/fluent-bit` (Debian-based system)
🤖 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 `@administration/configuring-fluent-bit/classic-mode/variables.md` at line 17,
The phrase "/etc/default/fluent-bit (Debian based system)" uses "Debian based"
as a compound modifier; update that text to read "/etc/default/fluent-bit
(Debian-based system)" so the compound adjective is hyphenated correctly.
🤖 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 `@administration/configuring-fluent-bit/yaml/environment-variables-section.md`:
- Around line 68-79: The "Default Values" section currently says defaults apply
only "if the variable is not defined"; update the text to state that the
`${VARIABLE_NAME:-DEFAULT_VALUE}` syntax supplies the DEFAULT_VALUE both when
the variable is unset and when it is defined but set to an empty string, so the
behavior matches the classic-mode doc; adjust the explanatory sentence and any
examples (the `service.flush: ${FLUSH_INTERVAL:-5}` example) to reflect this
dual-case behavior and ensure wording mirrors the classic-mode variables.md
description.

---

Nitpick comments:
In `@administration/configuring-fluent-bit/classic-mode/variables.md`:
- Around line 22-26: Replace the phrase "primary variable" with "the variable"
in the "Fallback Behavior" section describing the `${VARIABLE:-DEFAULT}` syntax
so the bullet points read that Fluent Bit will use the `DEFAULT` value if the
variable is not defined (unset) or is defined but set to an empty string; update
the sentence containing "primary variable" under the "Fallback Behavior" heading
to use "the variable" for clarity.
- Line 17: The phrase "/etc/default/fluent-bit (Debian based system)" uses
"Debian based" as a compound modifier; update that text to read
"/etc/default/fluent-bit (Debian-based system)" so the compound adjective is
hyphenated correctly.
🪄 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: 0131c310-bdb3-4583-bef3-ac293feb8a38

📥 Commits

Reviewing files that changed from the base of the PR and between 61734b0 and 032baeb.

📒 Files selected for processing (2)
  • administration/configuring-fluent-bit/classic-mode/variables.md
  • administration/configuring-fluent-bit/yaml/environment-variables-section.md

Comment thread administration/configuring-fluent-bit/yaml/environment-variables-section.md Outdated
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.

I don't believe this is correct, the variable defaulting syntax is inherent to the shell itself rather than the config file.

${MY_VARIABLE}
```
* **Standard:** `${MY_VARIABLE}`
* **With Default Value:** `${MY_VARIABLE:-default_value}`
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.

I don't think this is true, this is a bash shell syntax rather than anything with Fluent Bit itself.

Yes you can do this in bash outside of your Fluent Bit process but doing it in a Fluent Bit configuration file will not work - plus it won't work on targets like Windows either.

You could use it if you were setting them from the command line with a bash/posix shell but that's down to shell substitution.

e.g.

$ cat fluent-bit.conf
[INPUT]
  name dummy
  tag test
  dummy { "message": "${MY_TEST_VAR:-default}" }

[OUTPUT]
  name stdout
  match *
$ docker run --rm -it -v $PWD/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro fluent/fluent-bit:5.0.5
...
[2026/05/08 09:16:43.720] [ warn] [env] variable ${MY_TEST_VAR:-default} is used but not set
[2026/05/08 09:16:44.720] [ warn] [env] variable ${MY_TEST_VAR:-default} is used but not set
[0] test: [[1778231803.720809223, {}], {"message"=>""}]
[0] test: [[1778231804.720746078, {}], {"message"=>""}]

As you can see it's actually using the whole string as the name of the variable rather than any default expansion and you end up with an empty string because of it.

I could run it (on a compatible shell that supports this syntax) like so but this is down to the shell itself and not Fluent Bit:

$ docker run --rm -it fluent/fluent-bit:5.0.5 -i dummy -p dummy="{ \"message\": \"${MY_TEST_VAR:-default}\"}" -o stdout -m '*'
...
[2026/05/08 09:20:10.480] [ info] [output:stdout:stdout.0] worker #0 started
[0] dummy.0: [[1778232010.720772049, {}], {"message"=>"default"}]
[0] dummy.0: [[1778232011.720769028, {}], {"message"=>"default"}]

Copy link
Copy Markdown
Author

@benjaminmueggenburg-serato benjaminmueggenburg-serato May 8, 2026

Choose a reason for hiding this comment

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

Oh my apologies, I should've linked the original PR in the description:
fluent/fluent-bit#11787

This is the PR for the updated docs if the changes were to be merged 😄

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.

Ah right, that makes more sense!

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.

Can you update the description to include the links and a bit of description?
Relying on AI for it all is not great in my experience :)

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.

@benjaminmueggenburg-serato same for me, see comment @patrick-stephens above.

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.

Thanks for your reviews! I've updated the description and resolved the linting/coderabbit suggestions.

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.

@benjaminmueggenburg-serato my review requires some fixes first.

${MY_VARIABLE}
```
* **Standard:** `${MY_VARIABLE}`
* **With Default Value:** `${MY_VARIABLE:-default_value}`
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.

@benjaminmueggenburg-serato same for me, see comment @patrick-stephens above.

Comment thread administration/configuring-fluent-bit/classic-mode/variables.md Outdated
Comment thread administration/configuring-fluent-bit/classic-mode/variables.md Outdated
Comment thread administration/configuring-fluent-bit/yaml/environment-variables-section.md Outdated
Comment thread administration/configuring-fluent-bit/yaml/environment-variables-section.md Outdated
@eschabell eschabell added the waiting-on-review Waiting on a review from mainteners label May 8, 2026
Signed-off-by: benjaminmueggenburg-serato <benjamin.mueggenburg@serato.com>
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)
administration/configuring-fluent-bit/classic-mode/variables.md (1)

23-23: 💤 Low value

Consider simplifying "primary variable" to "variable".

The term "primary variable" is slightly awkward since there's no secondary variable being discussed. Simply "variable" would be more direct.

📝 Suggested simplification
-If the `${VARIABLE:-DEFAULT}` syntax is used, Fluent Bit will use the `DEFAULT` value if the primary variable meets either of the following conditions:
+If the `${VARIABLE:-DEFAULT}` syntax is used, Fluent Bit will use the `DEFAULT` value if the variable meets either of the following conditions:
🤖 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 `@administration/configuring-fluent-bit/classic-mode/variables.md` at line 23,
The sentence describing `${VARIABLE:-DEFAULT}` should use "variable" instead of
the awkward phrase "primary variable"; update the text "if the primary variable
meets either of the following conditions" to "if the variable meets either of
the following conditions" so the wording is simpler and clearer (refer to the
existing `${VARIABLE:-DEFAULT}` example in the same sentence).
🤖 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 `@administration/configuring-fluent-bit/classic-mode/variables.md`:
- Line 23: The sentence describing `${VARIABLE:-DEFAULT}` should use "variable"
instead of the awkward phrase "primary variable"; update the text "if the
primary variable meets either of the following conditions" to "if the variable
meets either of the following conditions" so the wording is simpler and clearer
(refer to the existing `${VARIABLE:-DEFAULT}` example in the same sentence).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b6cec43-41ac-45f9-a1c4-580ef970438b

📥 Commits

Reviewing files that changed from the base of the PR and between 032baeb and 4684811.

📒 Files selected for processing (2)
  • administration/configuring-fluent-bit/classic-mode/variables.md
  • administration/configuring-fluent-bit/yaml/environment-variables-section.md
✅ Files skipped from review due to trivial changes (1)
  • administration/configuring-fluent-bit/yaml/environment-variables-section.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on-code-merge waiting-on-review Waiting on a review from mainteners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants