Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ Fluent Bit supports the usage of environment variables in any value associated t

The variables are case sensitive and can be used in the following format:

```text
${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.


When Fluent Bit starts, the configuration reader will detect any request for `${MY_VARIABLE}` and will try to resolve its value.


When Fluent Bit is running under [`systemd`](https://systemd.io/) (using the official packages), environment variables can be set in the following files:

- `/etc/default/fluent-bit` (Debian based system)
- `/etc/sysconfig/fluent-bit` (Others)

These files are ignored if they don't exist.

### Fallback behavior
If the `${VARIABLE:-DEFAULT}` syntax is used, Fluent Bit will use the `DEFAULT` value if the primary variable meets either of the following conditions:
1. The variable **isn't defined** (unset).
2. The variable is defined but set to an **empty string** (`''`).

## Example

Create the following configuration file \(`fluent-bit.conf`\):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ pipeline:

In this example, `${DB_PASSWORD}` is read from the file `/run/secrets/db_password` and refreshed every 60 seconds. `${REGION}` is set to the static value `us-east-1`.

## Default values

Fluent Bit supports setting a default value for an environment variable if the variable isn't defined or is set to an empty string ('').

The syntax for a default value is `${VARIABLE_NAME:-DEFAULT_VALUE}`.

```yaml
service:
flush: ${FLUSH_INTERVAL:-5}
log_level: info
```

Comment thread
benjaminmueggenburg-serato marked this conversation as resolved.
## Predefined variables

Fluent Bit supports the following predefined environment variables. You can reference these variables in configuration files without defining them in the `env` section.
Expand Down