-
Notifications
You must be signed in to change notification settings - Fork 1
feature: add environment variable information and examples #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4cfeb71
feature: add environment variable information and examples
patrick-stephens be045e4
fix: resolve some niggles
patrick-stephens f611d80
refactor: move env var page under features
patrick-stephens 08b544a
fix: resolve some niggles
patrick-stephens f273ded
fix: resolve some niggles
patrick-stephens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| # Environment Variables | ||
|
|
||
| The Telemetry Forge Agent pre-populates a small set of runtime environment variables that you can always reference in Fluent Bit configuration files rather than have to set explicitly. | ||
|
|
||
| If a variable is already set in the process environment, the agent keeps that value unchanged. | ||
|
|
||
| These variables are available in Telemetry Forge Agent version 26.7.1 and later. | ||
|
|
||
| ## Supported variables | ||
|
|
||
| | Variable | Description | Default when not provided in process environment | | ||
| | --- | --- | --- | | ||
| | HOSTNAME | Host identity used by the running process. | System hostname (when available) | | ||
| | OS_TYPE | Normalised operating system name. | `linux`, `macos`, `windows`, or `unknown` | | ||
| | AGENT_DISTRO | Build distribution metadata. | [Value from build metadata](#agent_distro), or `unknown` | | ||
| | AGENT_PACKAGE_TYPE | Build package type metadata. | [Value from build metadata](#agent_package_type), or `unknown` | | ||
| | AGENT_VERSION | Agent version metadata. | [Value from build metadata](#agent_version), or `unknown` | | ||
|
|
||
| ## Values currently used in agent builds | ||
|
|
||
| These values are primarily for our [Fleet Manager](../../fleet-manager/index.md) but are available to all users as well. | ||
|
|
||
| ### AGENT_PACKAGE_TYPE | ||
|
|
||
| Current build values: | ||
|
|
||
| - `CONTAINER` (container image builds) | ||
| - `PACKAGE` (native package and installer builds) | ||
|
|
||
| ### AGENT_DISTRO | ||
|
|
||
| Current production build values are set based on our [supported targets](../supported-platforms.md) for each release but examples include: | ||
|
|
||
| - Container defaults: | ||
| - `debian/trixie` | ||
| - `ubi/10.2` | ||
| - Linux package build targets (release set): | ||
| - `almalinux/8` | ||
| - `almalinux/9` | ||
| - `almalinux/10` | ||
| - `amazonlinux/2023` | ||
| - `centos/6` | ||
| - `centos/7` | ||
| - `debian/bookworm` | ||
| - `debian/trixie` | ||
| - `ubuntu/22.04` | ||
| - `ubuntu/24.04` | ||
| - `ubuntu/26.04` | ||
| - `suse/15` | ||
| - Native package and installer platform values: | ||
| - `windows-x64` | ||
| - `macos-15` | ||
| - `macos-15-intel` | ||
|
|
||
| ### AGENT_VERSION | ||
|
|
||
| Current build values: | ||
|
|
||
| - Set from release/build metadata at build time | ||
| - Matches the agent release version (for example, `26.7.1`) | ||
| - See [Version Mapping](../version-mapping.md) for published version alignment | ||
|
|
||
| ## How values are resolved | ||
|
|
||
| Resolution order for each variable: | ||
|
|
||
| 1. Existing process environment value is kept as-is. | ||
| 2. If missing, the agent applies an internal preset configured at build time. | ||
| 3. If build metadata is unavailable for AGENT_DISTRO, AGENT_PACKAGE_TYPE, or AGENT_VERSION, the value is `unknown`. | ||
|
|
||
| ## Use in Fluent Bit configuration | ||
|
|
||
| You can reference the variables with [standard bash interpolation syntax](https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/yaml/environment-variables-section#external-variables). | ||
|
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| tag: env.test | ||
| dummy: '{"distro":"${AGENT_DISTRO}","package_type":"${AGENT_PACKAGE_TYPE}","version":"${AGENT_VERSION}","os":"${OS_TYPE}","hostname":"${HOSTNAME}"}' | ||
|
|
||
| outputs: | ||
| - name: stdout | ||
| match: env.test | ||
| ``` | ||
|
|
||
| Expected output when run with the Universal Base Image (UBI) container: | ||
|
|
||
| ```text | ||
| [0] env.test: [[<timestamp>, {}], {"distro"=>"ubi/10.2", "package_type"=>"CONTAINER", "version"=>"26.7.1", "os"=>"linux", "hostname"=>"my-host"}] | ||
| ``` | ||
|
|
||
| If you use the one-off or container overrides below, the `distro`, `package_type`, and `version` fields reflect the override values. | ||
|
|
||
| ## GitOps multi-platform example | ||
|
|
||
| You can use one Git repository for all operating systems and let `${OS_TYPE}` select the platform-specific configuration file automatically. | ||
|
|
||
| Example repository layout: | ||
|
|
||
| ```text | ||
| fluent-bit-configs/ | ||
| platforms/ | ||
| linux/fluent-bit.yaml | ||
| windows/fluent-bit.yaml | ||
| macos/fluent-bit.yaml | ||
| ``` | ||
|
|
||
| Agent configuration: | ||
|
|
||
| ```yaml | ||
| service: | ||
| flush: 1 | ||
| log_level: info | ||
|
|
||
| customs: | ||
| - name: git_config | ||
| repo: https://github.com/myorg/fluent-bit-configs.git | ||
| ref: main | ||
| path: platforms/${OS_TYPE}/fluent-bit.yaml | ||
| config_dir: /var/lib/fluent-bit/git-config | ||
| poll_interval: 60 | ||
| ``` | ||
|
|
||
| Path resolution examples: | ||
|
|
||
| - Linux agent: `platforms/linux/fluent-bit.yaml` | ||
| - Windows agent: `platforms/windows/fluent-bit.yaml` | ||
| - macOS agent: `platforms/macos/fluent-bit.yaml` | ||
|
|
||
| This lets you keep a single GitOps repository while still maintaining per-platform Fluent Bit configuration files. | ||
|
|
||
| ## Override examples | ||
|
|
||
| ### One-off process override | ||
|
|
||
| ```bash | ||
| AGENT_PACKAGE_TYPE=CONTAINER AGENT_DISTRO=ubuntu/24.04 AGENT_VERSION=26.7.1 \ | ||
| /opt/telemetryforge-agent/bin/fluent-bit -c ./fluent-bit.yaml | ||
| ``` | ||
|
|
||
| ### Container override | ||
|
|
||
| ```bash | ||
| docker run --rm \ | ||
| -e AGENT_DISTRO=ubuntu/24.04 \ | ||
| -e AGENT_PACKAGE_TYPE=CONTAINER \ | ||
| -e AGENT_VERSION=26.7.1 \ | ||
| -v "$PWD/fluent-bit.yaml:/fluent-bit/etc/fluent-bit.yaml:ro" \ | ||
| ghcr.io/telemetryforge/agent:26.7.1 \ | ||
| -c /fluent-bit/etc/fluent-bit.yaml | ||
| ``` | ||
|
|
||
| ### systemd service override | ||
|
|
||
| Add to your service unit: | ||
|
|
||
| ```ini | ||
| [Service] | ||
| Environment=AGENT_DISTRO=rhel/9 | ||
| Environment=AGENT_PACKAGE_TYPE=PACKAGE | ||
| Environment=AGENT_VERSION=26.7.1 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.