Skip to content

Commit 099ba5a

Browse files
committed
docs: administration: yaml: document extended env list form
- Add map form and extended list form headings to organize existing and new content - Document extended list form properties: name, value, uri, and refresh_interval - Add YAML example showing file-backed secrets with automatic refresh - Explain runtime refresh behavior for file:// URI-backed variables This update for code commits without supporting docs PR. Signed-off-by: Eric D. Schabell <eric@schabell.org>
1 parent 67f97c7 commit 099ba5a

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

administration/configuring-fluent-bit/yaml/environment-variables-section.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Environment variables
22

3-
The `env` section of YAML configuration files lets you define environment variables. These variables can then be used to dynamically replace values throughout your configuration using the `${VARIABLE_NAME}` syntax.
3+
The `env` section of YAML configuration files lets you define environment variables. These variables can then be used to dynamically replace values throughout your configuration using the `${VARIABLE_NAME}` syntax. The `env` section supports two forms: a map form for static key-value pairs and an extended list form for advanced use cases like file-backed secrets with automatic refresh.
44

5-
Values set in the `env` section are case-sensitive. However, as a best practice, Fluent Bit recommends using uppercase names for environment variables. The following example defines two variables, `FLUSH_INTERVAL` and `STDOUT_FMT`, which can be accessed in the configuration using `${FLUSH_INTERVAL}` and `${STDOUT_FMT}`:
5+
Values set in the `env` section are case-sensitive. However, as a best practice, Fluent Bit recommends using uppercase names for environment variables.
6+
7+
## Map form
8+
9+
The map form defines variables as key-value pairs. The following example defines two variables, `FLUSH_INTERVAL` and `STDOUT_FMT`, which can be accessed in the configuration using `${FLUSH_INTERVAL}` and `${STDOUT_FMT}`:
610

711
```yaml
812
env:
@@ -23,6 +27,44 @@ pipeline:
2327
format: ${STDOUT_FMT}
2428
```
2529
30+
## Extended list form
31+
32+
The `env` section also accepts a YAML list of entries. Each entry is a mapping with the following properties:
33+
34+
| Property | Required | Description |
35+
| :------- | :------- | :---------- |
36+
| `name` | Yes | The name of the environment variable. |
37+
| `value` | No | An explicit value for the variable. Mutually exclusive with `uri`. |
38+
| `uri` | No | A URI pointing to the variable's value source. Currently supports `file://` `URIs` (for example, `file:///run/secrets/my_secret`). The file contents are read and used as the variable's value. |
39+
| `refresh_interval` | No | How often (in seconds) to re-read the value from the `uri` source. Only meaningful when `uri` is set. Default is `0` (read once at startup). |
40+
41+
Either `value` or `uri` must be provided for each entry.
42+
43+
When `uri` and `refresh_interval` are both set, Fluent Bit re-reads the file at the specified interval. This enables dynamic configuration values, such as rotating secrets, without restarting Fluent Bit. If `refresh_interval` is `0` or omitted, the file is read only once at startup.
44+
45+
```yaml
46+
env:
47+
- name: DB_PASSWORD
48+
uri: file:///run/secrets/db_password
49+
refresh_interval: 60
50+
- name: REGION
51+
value: us-east-1
52+
53+
service:
54+
flush: 1
55+
log_level: info
56+
57+
pipeline:
58+
inputs:
59+
- name: random
60+
61+
outputs:
62+
- name: stdout
63+
match: '*'
64+
```
65+
66+
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`.
67+
2668
## Predefined variables
2769

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

0 commit comments

Comments
 (0)