From 468481140c1f3274777e0e4ae3cde8694b112707 Mon Sep 17 00:00:00 2001 From: benjaminmueggenburg-serato Date: Mon, 11 May 2026 08:56:12 +1200 Subject: [PATCH] docs: env: bash-style default value operator :- Signed-off-by: benjaminmueggenburg-serato --- .../configuring-fluent-bit/classic-mode/variables.md | 11 ++++++++--- .../yaml/environment-variables-section.md | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/administration/configuring-fluent-bit/classic-mode/variables.md b/administration/configuring-fluent-bit/classic-mode/variables.md index 1cfaf3e5b..1d16aeda5 100644 --- a/administration/configuring-fluent-bit/classic-mode/variables.md +++ b/administration/configuring-fluent-bit/classic-mode/variables.md @@ -6,12 +6,12 @@ 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}` 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) @@ -19,6 +19,11 @@ When Fluent Bit is running under [`systemd`](https://systemd.io/) (using the off 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`\): diff --git a/administration/configuring-fluent-bit/yaml/environment-variables-section.md b/administration/configuring-fluent-bit/yaml/environment-variables-section.md index 2553d9181..c3e80c672 100644 --- a/administration/configuring-fluent-bit/yaml/environment-variables-section.md +++ b/administration/configuring-fluent-bit/yaml/environment-variables-section.md @@ -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 +``` + ## 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.