liveBook · Manning

Environment variable

As explained in Logs and Telemetry

An environment variable is a named value supplied by the operating system or process environment and made available to applications at runtime.

An environment variable is a named runtime value that makes Fluent Bit configuration dynamic. Use it to keep one monitoring configuration while changing destinations, credentials, tags, or other environment-specific values. section 2.5

Apply environment variables in Fluent Bit by:

  • Defining a value before startup, such as Linux's `export myTag=my-dummy-tag`; Windows uses `set` instead. section 2.5.1
  • Referencing the value with `${myTag}` inside configuration expressions. section 2.5.1
  • Running Fluent Bit with the configuration; a resolved value changes the resulting tag, while an unset value causes an unknown-property error. section 2.5.1
  • Using Modify or Record filters when an attribute requires a literal string rather than environment-variable substitution. section 2.5.1

Change a Fluent Bit tag at startup

Set `myTag` with `export myTag=my-dummy-tag`, then use `tag ${myTag}` in the input configuration and run `fluent-bit -c hello-world-variable.conf`. The output uses `my-dummy-tag` instead of `dummy1`; omitting the variable prevents successful resolution. section 2.5.1

Listing 2.9 Using environment variables
[input]
  name dummy
  dummy {"hello":"my world"}
  tag ${myTag}              #1

The configuration fragment shows environment-variable syntax directly in a Fluent Bit input definition. section 2.5.1

Fluent Bit can also assign variables with `@set`, making shared values portable across operating systems and included configuration files. An `@set` value overrides an OS-level variable with the same name. section 2.5.2

In containers, injected environment variables can identify instances and let a Fluent Bit sidecar add context without coupling application code to a deployment environment. section 4.6

How Logs and Telemetry covers it

How deep it goes
Explains shell setup, substitution syntax, startup failures, filter constraints, and configuration-level overrides.
Examples
Demonstrates `${myTag}`, shell export, `fluent-bit -c`, and `@set` through changing a Hello World tag.
What it assumes
Assumes basic Fluent Bit configuration and shell usage while demonstrating variable substitution from the beginning.
What you can do after
Operate/configure Fluent Bit with shell-provided and configuration-defined values, while diagnosing unresolved substitutions.
How it connects
Connects environment variables with Fluent Bit configuration, Modify filters, Record filters, logging frameworks, and the sidecar pattern.

Also explained in

Compare how 19 books explain environment variable →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Logs and Telemetry. The section links point to the parts of the book it draws on.