From fdc2b201dabfa057ff0d76b62158fed63eb40ccb Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 15:18:34 +0100
Subject: [PATCH 01/14] feat: add OS_TYPE environment variable

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/src/flb_env.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/source/src/flb_env.c b/source/src/flb_env.c
index e4cfcff6..177b48d6 100644
--- a/source/src/flb_env.c
+++ b/source/src/flb_env.c
@@ -64,6 +64,25 @@ static int env_preset(struct flb_env *env)
         }
     }
 
+
+    /*
+     * ${OS_TYPE} this variable is useful to identify the operating system
+     * where the agent is running, if it is not set, we will try to detect
+     * it and set it as a default variable.
+     */
+    buf = getenv("OS_TYPE");
+    if (!buf) {
+#if defined(FLB_SYSTEM_WINDOWS)
+        flb_env_set(env, "OS_TYPE", "windows");
+#elif defined(FLB_SYSTEM_MACOS)
+        flb_env_set(env, "OS_TYPE", "macos");
+#elif defined(FLB_SYSTEM_LINUX)
+        flb_env_set(env, "OS_TYPE", "linux");
+#else
+        flb_env_set(env, "OS_TYPE", "unknown");
+#endif
+    }
+
     return 0;
 }
 

From 4c67370e262e9b00f12330ec6c871664ba3da401 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 15:23:25 +0100
Subject: [PATCH 02/14] test: add test cases for environment variable presets
 and overrides

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/tests/internal/env.c | 122 ++++++++++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)

diff --git a/source/tests/internal/env.c b/source/tests/internal/env.c
index 1f471224..1bb351dc 100644
--- a/source/tests/internal/env.c
+++ b/source/tests/internal/env.c
@@ -23,8 +23,128 @@
 #include <fluent-bit/flb_sds.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "flb_tests_internal.h"
 
+static const char *expected_os_type()
+{
+#if defined(FLB_SYSTEM_WINDOWS)
+    return "windows";
+#elif defined(FLB_SYSTEM_MACOS)
+    return "macos";
+#elif defined(FLB_SYSTEM_LINUX)
+    return "linux";
+#else
+    return "unknown";
+#endif
+}
+
+void test_preset_env_defaults()
+{
+    struct flb_env *env;
+    const char *hostname;
+    const char *os_type;
+
+    env = flb_env_create();
+    if (!TEST_CHECK(env != NULL)) {
+        TEST_MSG("flb_env_create failed");
+        exit(1);
+    }
+
+    hostname = flb_env_get(env, "HOSTNAME");
+    if (!TEST_CHECK(hostname != NULL && strlen(hostname) > 0)) {
+        TEST_MSG("HOSTNAME preset is missing");
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    os_type = flb_env_get(env, "OS_TYPE");
+    if (!TEST_CHECK(os_type != NULL && strlen(os_type) > 0)) {
+        TEST_MSG("OS_TYPE preset is missing");
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    if (!TEST_CHECK(strcmp(os_type, expected_os_type()) == 0)) {
+        TEST_MSG("OS_TYPE mismatch. Got=%s expect=%s", os_type, expected_os_type());
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    flb_env_destroy(env);
+}
+
+void test_preset_env_overrides()
+{
+    struct flb_env *env;
+    const char *hostname;
+    const char *os_type;
+    const char *override_hostname = "env-test-host";
+    const char *override_os_type = "env-test-os";
+    int ret;
+    char hostname_arg[128];
+    char os_type_arg[128];
+
+    snprintf(hostname_arg, sizeof(hostname_arg), "HOSTNAME=%s", override_hostname);
+    snprintf(os_type_arg, sizeof(os_type_arg), "OS_TYPE=%s", override_os_type);
+
+#if defined(FLB_SYSTEM_WINDOWS)
+    ret = _putenv(hostname_arg);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("_putenv HOSTNAME failed");
+        exit(1);
+    }
+
+    ret = _putenv(os_type_arg);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("_putenv OS_TYPE failed");
+        exit(1);
+    }
+#else
+    ret = setenv("HOSTNAME", override_hostname, 1);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("setenv HOSTNAME failed");
+        exit(1);
+    }
+
+    ret = setenv("OS_TYPE", override_os_type, 1);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("setenv OS_TYPE failed");
+        exit(1);
+    }
+#endif
+
+    env = flb_env_create();
+    if (!TEST_CHECK(env != NULL)) {
+        TEST_MSG("flb_env_create failed");
+        exit(1);
+    }
+
+    hostname = flb_env_get(env, "HOSTNAME");
+    if (!TEST_CHECK(hostname != NULL && strcmp(hostname, override_hostname) == 0)) {
+        TEST_MSG("HOSTNAME override lost. Got=%s expect=%s", hostname, override_hostname);
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    os_type = flb_env_get(env, "OS_TYPE");
+    if (!TEST_CHECK(os_type != NULL && strcmp(os_type, override_os_type) == 0)) {
+        TEST_MSG("OS_TYPE override lost. Got=%s expect=%s", os_type, override_os_type);
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    flb_env_destroy(env);
+
+#if defined(FLB_SYSTEM_WINDOWS)
+    _putenv("HOSTNAME=");
+    _putenv("OS_TYPE=");
+#else
+    unsetenv("HOSTNAME");
+    unsetenv("OS_TYPE");
+#endif
+}
+
 /* https://github.com/fluent/fluent-bit/issues/6313 */
 void test_translate_long_env()
 {
@@ -86,6 +206,8 @@ void test_translate_long_env()
 
 
 TEST_LIST = {
+    { "preset_env_defaults"         , test_preset_env_defaults},
+    { "preset_env_overrides"        , test_preset_env_overrides},
     { "translate_long_env"           , test_translate_long_env},
     { NULL, NULL }
 };

From 473236f40f0cbdb2ad36be8fdfb3a8c98f534afd Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 15:35:25 +0100
Subject: [PATCH 03/14] feat: add TELEMETRY_FORGE_ environment variables

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/CMakeLists.txt         |  11 ---
 source/cmake/enterprise.cmake |  17 +++++
 source/src/flb_env.c          |  45 ++++++++++++
 source/tests/internal/env.c   | 129 ++++++++++++++++++++++++++++++++++
 4 files changed, 191 insertions(+), 11 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index b37dcf8b..84228b86 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -228,17 +228,6 @@ if(DEFINED FLB_NIGHTLY_BUILD AND NOT "${FLB_NIGHTLY_BUILD}" STREQUAL "")
   FLB_DEFINITION_VAL(FLB_NIGHTLY_BUILD ${FLB_NIGHTLY_BUILD})
 endif()
 
-# Build metadata: distribution and package type
-if(DEFINED TELEMETRY_FORGE_AGENT_DISTRO AND NOT "${TELEMETRY_FORGE_AGENT_DISTRO}" STREQUAL "")
-  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_DISTRO ${TELEMETRY_FORGE_AGENT_DISTRO})
-  message(STATUS "Build distro: ${TELEMETRY_FORGE_AGENT_DISTRO}")
-endif()
-
-if(DEFINED TELEMETRY_FORGE_AGENT_PACKAGE_TYPE AND NOT "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}" STREQUAL "")
-  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE})
-  message(STATUS "Build package type: ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}")
-endif()
-
 if(FLB_IN_STORAGE_BACKLOG)
   FLB_DEFINITION(FLB_HAVE_IN_STORAGE_BACKLOG)
 endif()
diff --git a/source/cmake/enterprise.cmake b/source/cmake/enterprise.cmake
index a7e97aac..ae4fabea 100644
--- a/source/cmake/enterprise.cmake
+++ b/source/cmake/enterprise.cmake
@@ -18,3 +18,20 @@ function(validate_required_options)
 
     message(STATUS "All required options validated successfully")
 endfunction()
+
+# Build metadata: distribution and package type
+if(DEFINED TELEMETRY_FORGE_AGENT_DISTRO AND NOT "${TELEMETRY_FORGE_AGENT_DISTRO}" STREQUAL "")
+  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_DISTRO ${TELEMETRY_FORGE_AGENT_DISTRO})
+  message(STATUS "Build distro: ${TELEMETRY_FORGE_AGENT_DISTRO}")
+endif()
+
+if(DEFINED TELEMETRY_FORGE_AGENT_PACKAGE_TYPE AND NOT "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}" STREQUAL "")
+  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE})
+  message(STATUS "Build package type: ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}")
+endif()
+
+# Build metadata: version set by the build or default to the FLB_VERSION_STR version defined in the root file
+if(DEFINED TELEMETRY_FORGE_AGENT_VERSION AND NOT "${TELEMETRY_FORGE_AGENT_VERSION}" STREQUAL "")
+  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_VERSION ${FLB_VERSION_STR})
+  message(STATUS "Build agent version: ${TELEMETRY_FORGE_AGENT_VERSION}")
+endif()
diff --git a/source/src/flb_env.c b/source/src/flb_env.c
index 177b48d6..eba44aa0 100644
--- a/source/src/flb_env.c
+++ b/source/src/flb_env.c
@@ -27,6 +27,10 @@
 
 #include <stdlib.h>
 
+/* Macro for stringifying build metadata */
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
 static inline flb_sds_t buf_append(flb_sds_t buf, const char *str, int len)
 {
     flb_sds_t tmp;
@@ -83,6 +87,47 @@ static int env_preset(struct flb_env *env)
 #endif
     }
 
+    /*
+     * ${TELEMETRY_FORGE_AGENT_DISTRO} this variable is useful to identify the distribution
+     * where the agent is running, if it is not set, we will set it based on build metadata.
+     * This is especially useful for Linux, where we have multiple distros and
+     * we want to be able to identify them.
+     */
+    buf = getenv("TELEMETRY_FORGE_AGENT_DISTRO");
+    if (!buf) {
+#if defined(TELEMETRY_FORGE_AGENT_DISTRO)
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_DISTRO", TOSTRING(TELEMETRY_FORGE_AGENT_DISTRO));
+#else
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_DISTRO", "unknown");
+#endif
+    }
+
+    /*
+     * ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE} this variable is useful to identify the package type
+     * of the agent, if it is not set, we will set it based on build metadata .
+     */
+    buf = getenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    if (!buf) {
+#if defined(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE)
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", TOSTRING(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE));
+#else
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", "unknown");
+#endif
+    }
+
+    /*
+     * ${TELEMETRY_FORGE_AGENT_VERSION} this variable is useful to identify the version
+     * of the agent, if it is not set, we will set it based on build metadata .
+     */
+    buf = getenv("TELEMETRY_FORGE_AGENT_VERSION");
+    if (!buf) {
+#if defined(TELEMETRY_FORGE_AGENT_VERSION)
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_VERSION", TOSTRING(TELEMETRY_FORGE_AGENT_VERSION));
+#else
+        flb_env_set(env, "TELEMETRY_FORGE_AGENT_VERSION", "unknown");
+#endif
+    }
+
     return 0;
 }
 
diff --git a/source/tests/internal/env.c b/source/tests/internal/env.c
index 1bb351dc..cc5f185f 100644
--- a/source/tests/internal/env.c
+++ b/source/tests/internal/env.c
@@ -26,6 +26,9 @@
 #include <string.h>
 #include "flb_tests_internal.h"
 
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
 static const char *expected_os_type()
 {
 #if defined(FLB_SYSTEM_WINDOWS)
@@ -39,11 +42,41 @@ static const char *expected_os_type()
 #endif
 }
 
+static const char *expected_agent_distro()
+{
+#if defined(TELEMETRY_FORGE_AGENT_DISTRO)
+    return TOSTRING(TELEMETRY_FORGE_AGENT_DISTRO);
+#else
+    return "unknown";
+#endif
+}
+
+static const char *expected_agent_package_type()
+{
+#if defined(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE)
+    return TOSTRING(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE);
+#else
+    return "unknown";
+#endif
+}
+
+static const char *expected_agent_version()
+{
+#if defined(TELEMETRY_FORGE_AGENT_VERSION)
+    return TOSTRING(TELEMETRY_FORGE_AGENT_VERSION);
+#else
+    return "unknown";
+#endif
+}
+
 void test_preset_env_defaults()
 {
     struct flb_env *env;
     const char *hostname;
     const char *os_type;
+    const char *agent_distro;
+    const char *agent_package_type;
+    const char *agent_version;
 
     env = flb_env_create();
     if (!TEST_CHECK(env != NULL)) {
@@ -71,6 +104,27 @@ void test_preset_env_defaults()
         exit(1);
     }
 
+    agent_distro = flb_env_get(env, "TELEMETRY_FORGE_AGENT_DISTRO");
+    if (!TEST_CHECK(agent_distro != NULL && strcmp(agent_distro, expected_agent_distro()) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_DISTRO mismatch. Got=%s expect=%s", agent_distro, expected_agent_distro());
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    agent_package_type = flb_env_get(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    if (!TEST_CHECK(agent_package_type != NULL && strcmp(agent_package_type, expected_agent_package_type()) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE mismatch. Got=%s expect=%s", agent_package_type, expected_agent_package_type());
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    agent_version = flb_env_get(env, "TELEMETRY_FORGE_AGENT_VERSION");
+    if (!TEST_CHECK(agent_version != NULL && strcmp(agent_version, expected_agent_version()) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_VERSION mismatch. Got=%s expect=%s", agent_version, expected_agent_version());
+        flb_env_destroy(env);
+        exit(1);
+    }
+
     flb_env_destroy(env);
 }
 
@@ -81,12 +135,24 @@ void test_preset_env_overrides()
     const char *os_type;
     const char *override_hostname = "env-test-host";
     const char *override_os_type = "env-test-os";
+    const char *agent_distro;
+    const char *agent_package_type;
+    const char *agent_version;
+    const char *override_agent_distro = "env-test-distro";
+    const char *override_agent_package_type = "env-test-package";
+    const char *override_agent_version = "env-test-version";
     int ret;
     char hostname_arg[128];
     char os_type_arg[128];
+    char agent_distro_arg[128];
+    char agent_package_type_arg[128];
+    char agent_version_arg[128];
 
     snprintf(hostname_arg, sizeof(hostname_arg), "HOSTNAME=%s", override_hostname);
     snprintf(os_type_arg, sizeof(os_type_arg), "OS_TYPE=%s", override_os_type);
+    snprintf(agent_distro_arg, sizeof(agent_distro_arg), "TELEMETRY_FORGE_AGENT_DISTRO=%s", override_agent_distro);
+    snprintf(agent_package_type_arg, sizeof(agent_package_type_arg), "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=%s", override_agent_package_type);
+    snprintf(agent_version_arg, sizeof(agent_version_arg), "TELEMETRY_FORGE_AGENT_VERSION=%s", override_agent_version);
 
 #if defined(FLB_SYSTEM_WINDOWS)
     ret = _putenv(hostname_arg);
@@ -100,6 +166,24 @@ void test_preset_env_overrides()
         TEST_MSG("_putenv OS_TYPE failed");
         exit(1);
     }
+
+    ret = _putenv(agent_distro_arg);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_DISTRO failed");
+        exit(1);
+    }
+
+    ret = _putenv(agent_package_type_arg);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_PACKAGE_TYPE failed");
+        exit(1);
+    }
+
+    ret = _putenv(agent_version_arg);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_VERSION failed");
+        exit(1);
+    }
 #else
     ret = setenv("HOSTNAME", override_hostname, 1);
     if (!TEST_CHECK(ret == 0)) {
@@ -112,6 +196,24 @@ void test_preset_env_overrides()
         TEST_MSG("setenv OS_TYPE failed");
         exit(1);
     }
+
+    ret = setenv("TELEMETRY_FORGE_AGENT_DISTRO", override_agent_distro, 1);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_DISTRO failed");
+        exit(1);
+    }
+
+    ret = setenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", override_agent_package_type, 1);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_PACKAGE_TYPE failed");
+        exit(1);
+    }
+
+    ret = setenv("TELEMETRY_FORGE_AGENT_VERSION", override_agent_version, 1);
+    if (!TEST_CHECK(ret == 0)) {
+        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_VERSION failed");
+        exit(1);
+    }
 #endif
 
     env = flb_env_create();
@@ -134,14 +236,41 @@ void test_preset_env_overrides()
         exit(1);
     }
 
+    agent_distro = flb_env_get(env, "TELEMETRY_FORGE_AGENT_DISTRO");
+    if (!TEST_CHECK(agent_distro != NULL && strcmp(agent_distro, override_agent_distro) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_DISTRO override lost. Got=%s expect=%s", agent_distro, override_agent_distro);
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    agent_package_type = flb_env_get(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    if (!TEST_CHECK(agent_package_type != NULL && strcmp(agent_package_type, override_agent_package_type) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE override lost. Got=%s expect=%s", agent_package_type, override_agent_package_type);
+        flb_env_destroy(env);
+        exit(1);
+    }
+
+    agent_version = flb_env_get(env, "TELEMETRY_FORGE_AGENT_VERSION");
+    if (!TEST_CHECK(agent_version != NULL && strcmp(agent_version, override_agent_version) == 0)) {
+        TEST_MSG("TELEMETRY_FORGE_AGENT_VERSION override lost. Got=%s expect=%s", agent_version, override_agent_version);
+        flb_env_destroy(env);
+        exit(1);
+    }
+
     flb_env_destroy(env);
 
 #if defined(FLB_SYSTEM_WINDOWS)
     _putenv("HOSTNAME=");
     _putenv("OS_TYPE=");
+    _putenv("TELEMETRY_FORGE_AGENT_DISTRO=");
+    _putenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=");
+    _putenv("TELEMETRY_FORGE_AGENT_VERSION=");
 #else
     unsetenv("HOSTNAME");
     unsetenv("OS_TYPE");
+    unsetenv("TELEMETRY_FORGE_AGENT_DISTRO");
+    unsetenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    unsetenv("TELEMETRY_FORGE_AGENT_VERSION");
 #endif
 }
 

From b603b61b6cf63f3946885eeed338e16efbaf71b3 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 15:47:19 +0100
Subject: [PATCH 04/14] ci: set macos variables

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 .github/workflows/call-build-macos-packages.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.github/workflows/call-build-macos-packages.yaml b/.github/workflows/call-build-macos-packages.yaml
index 6cebe6ba..dbcf6c28 100644
--- a/.github/workflows/call-build-macos-packages.yaml
+++ b/.github/workflows/call-build-macos-packages.yaml
@@ -98,6 +98,10 @@ jobs:
             -DOPENSSL_USE_STATIC_LIBS=ON \
             -DCMAKE_BUILD_TYPE=Release \
             -DCPACK_GENERATOR=productbuild \
+            -DTELEMETRY_FORGE_AGENT_DISTRO=${{ matrix.config.runner }} \
+            -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE=PACKAGE \
+            -DFLUENTDO_AGENT_DISTRO=${{ matrix.config.runner }} \
+            -DFLUENTDO_AGENT_PACKAGE_TYPE=PACKAGE \
             -DFLB_NIGHTLY_BUILD=${{ inputs.nightly-build-info }} ../
 
           cmake --build .

From 0983d4484d17b05a7a9c896896980d195f9a128a Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 15:53:20 +0100
Subject: [PATCH 05/14] fix: make distro and package type variables mandatory

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/cmake/enterprise.cmake | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/source/cmake/enterprise.cmake b/source/cmake/enterprise.cmake
index ae4fabea..f7caeaf1 100644
--- a/source/cmake/enterprise.cmake
+++ b/source/cmake/enterprise.cmake
@@ -19,19 +19,25 @@ function(validate_required_options)
     message(STATUS "All required options validated successfully")
 endfunction()
 
-# Build metadata: distribution and package type
-if(DEFINED TELEMETRY_FORGE_AGENT_DISTRO AND NOT "${TELEMETRY_FORGE_AGENT_DISTRO}" STREQUAL "")
-  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_DISTRO ${TELEMETRY_FORGE_AGENT_DISTRO})
-  message(STATUS "Build distro: ${TELEMETRY_FORGE_AGENT_DISTRO}")
+# Build metadata: all variables are mandatory for enterprise builds
+if(NOT DEFINED TELEMETRY_FORGE_AGENT_DISTRO OR "${TELEMETRY_FORGE_AGENT_DISTRO}" STREQUAL "")
+  message(FATAL_ERROR "TELEMETRY_FORGE_AGENT_DISTRO must be set for enterprise builds")
 endif()
 
-if(DEFINED TELEMETRY_FORGE_AGENT_PACKAGE_TYPE AND NOT "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}" STREQUAL "")
-  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE})
-  message(STATUS "Build package type: ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}")
+if(NOT DEFINED TELEMETRY_FORGE_AGENT_PACKAGE_TYPE OR "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}" STREQUAL "")
+  message(FATAL_ERROR "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE must be set for enterprise builds")
 endif()
 
-# Build metadata: version set by the build or default to the FLB_VERSION_STR version defined in the root file
-if(DEFINED TELEMETRY_FORGE_AGENT_VERSION AND NOT "${TELEMETRY_FORGE_AGENT_VERSION}" STREQUAL "")
-  FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_VERSION ${FLB_VERSION_STR})
-  message(STATUS "Build agent version: ${TELEMETRY_FORGE_AGENT_VERSION}")
+if(NOT DEFINED TELEMETRY_FORGE_AGENT_VERSION OR "${TELEMETRY_FORGE_AGENT_VERSION}" STREQUAL "")
+  set(TELEMETRY_FORGE_AGENT_VERSION ${FLB_VERSION_STR})
+  message(STATUS "TELEMETRY_FORGE_AGENT_VERSION not set, defaulting to FLB_VERSION_STR=${FLB_VERSION_STR}")
 endif()
+
+FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_DISTRO ${TELEMETRY_FORGE_AGENT_DISTRO})
+message(STATUS "Build distro: ${TELEMETRY_FORGE_AGENT_DISTRO}")
+
+FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE})
+message(STATUS "Build package type: ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}")
+
+FLB_DEFINITION_VAL(TELEMETRY_FORGE_AGENT_VERSION ${TELEMETRY_FORGE_AGENT_VERSION})
+message(STATUS "Build agent version: ${TELEMETRY_FORGE_AGENT_VERSION}")

From 4f72777f949dc3a22a0dfa0487afe2ce477a9c91 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:33:17 +0100
Subject: [PATCH 06/14] ci: ensure we set variables for all builds

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 .github/workflows/call-build-macos-packages.yaml | 2 --
 .github/workflows/unit-tests.yaml                | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/call-build-macos-packages.yaml b/.github/workflows/call-build-macos-packages.yaml
index dbcf6c28..00dd2791 100644
--- a/.github/workflows/call-build-macos-packages.yaml
+++ b/.github/workflows/call-build-macos-packages.yaml
@@ -100,8 +100,6 @@ jobs:
             -DCPACK_GENERATOR=productbuild \
             -DTELEMETRY_FORGE_AGENT_DISTRO=${{ matrix.config.runner }} \
             -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE=PACKAGE \
-            -DFLUENTDO_AGENT_DISTRO=${{ matrix.config.runner }} \
-            -DFLUENTDO_AGENT_PACKAGE_TYPE=PACKAGE \
             -DFLB_NIGHTLY_BUILD=${{ inputs.nightly-build-info }} ../
 
           cmake --build .
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index 5007d331..7144acfd 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -120,6 +120,9 @@ jobs:
             FLB_BACKTRACE=Off
             FLB_SHARED_LIB=Off
 
+            TELEMETRY_FORGE_AGENT_DISTRO=ubuntu/latest
+            TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=PACKAGE
+
             ${{ matrix.config.options }}
           run-build: false
 

From e964ab34977ee5824728aab50a9a6e6772ebfcd3 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:33:32 +0100
Subject: [PATCH 07/14] test: add integration test for preset variables

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 .../resources/environment-fluent-bit.yaml     | 21 ++++++
 .../functional/common/verify-environment.bats | 71 +++++++++++++++++++
 2 files changed, 92 insertions(+)
 create mode 100644 testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
 create mode 100644 testing/bats/tests/functional/common/verify-environment.bats

diff --git a/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml b/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
new file mode 100644
index 00000000..8a628596
--- /dev/null
+++ b/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
@@ -0,0 +1,21 @@
+service:
+  flush: 1
+  grace: 1
+  log_level: info
+
+pipeline:
+  inputs:
+    - name: dummy
+      # We use the environment variables to verify that they are set correctly based on the build and packaging configuration of the agent.
+      dummy: '{"distro": "${TELEMETRY_FORGE_AGENT_DISTRO}", "package_type": "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}", "version": "${TELEMETRY_FORGE_AGENT_VERSION}", "os": "${OS_TYPE}"}'
+      alias: input_dummy
+
+  outputs:
+    - name: stdout
+      match: '*'
+      alias: output_stdout
+    - name: exit
+      match: '*'
+      # Exit after processing 2 records to ensure the test completes in a reasonable time frame
+      record_count: 2
+      alias: output_exit
diff --git a/testing/bats/tests/functional/common/verify-environment.bats b/testing/bats/tests/functional/common/verify-environment.bats
new file mode 100644
index 00000000..b25c10ab
--- /dev/null
+++ b/testing/bats/tests/functional/common/verify-environment.bats
@@ -0,0 +1,71 @@
+#!/usr/bin/env bats
+
+load "$HELPERS_ROOT/test-helpers.bash"
+
+ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENT_BIT_BINARY TELEMETRY_FORGE_AGENT_VERSION
+
+load "$BATS_SUPPORT_ROOT/load.bash"
+load "$BATS_ASSERT_ROOT/load.bash"
+load "$BATS_FILE_ROOT/load.bash"
+
+# bats file_tags=functional
+
+@test "verify preset env vars are always set" {
+    run "$FLUENT_BIT_BINARY" --help
+    assert_success
+
+    # Check that the env vars are set
+    assert_output --partial 'TELEMETRY_FORGE_AGENT_DISTRO'
+    assert_output --partial 'TELEMETRY_FORGE_AGENT_PACKAGE_TYPE'
+    assert_output --partial 'TELEMETRY_FORGE_AGENT_VERSION'
+}
+
+@test "verify preset env vars have correct values" {
+    # We run Fluent Bit with a dummy input that uses the env vars in the config to ensure they are set and have correct values.
+    # This will also use a stdout output plugin to print out the dummy record which will contain the env vars in the output, allowing us to assert on their values.
+    # Finally we include an exit plugin to ensure Fluent Bit exits after processing the dummy record or with a time delay, otherwise it would run indefinitely and the test would timeout.
+
+    assert_file_exists "$BATS_TEST_DIRNAME/resources/environment-fluent-bit.yaml"
+    # Dry run initially to verify the config is valid
+    run "$FLUENT_BIT_BINARY" -c "$BATS_TEST_DIRNAME/resources/environment-fluent-bit.yaml" --dry-run
+    assert_success
+    refute_output --partial "[error]"
+
+    # Now run it for real and check the output contains the env vars with correct values
+    run "$FLUENT_BIT_BINARY" -c "$BATS_TEST_DIRNAME/resources/environment-fluent-bit.yaml"
+    assert_success
+    refute_output --partial "[error]"
+
+    # The input string is '{"distro": "${TELEMETRY_FORGE_AGENT_DISTRO}", "package_type": "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}", "version": "${TELEMETRY_FORGE_AGENT_VERSION}", "os": "${OS_TYPE}"}'
+    # distro will be set to a value like "ubuntu/latest" or "amazonlinux/2023"
+    # package_type will be set to "PACKAGE" or "CONTAINER"
+    # version will be set to the agent version like "0.1.0"
+    # os will be set to the OS type like "linux" or "darwin"
+
+    # We can assert on the output to check that the env vars are set and have correct values. We will check that distro, package_type, version and os are all present in the output with expected values.
+
+    # distro should be set to a value like "ubuntu/latest" or "amazonlinux/2023" plus macos/windows variants so we can just check that it is set to some value and not empty
+    assert_output --partial "distro="
+
+    if [ -z "${TELEMETRY_FORGE_AGENT_IMAGE:-}" ]; then
+        # If TELEMETRY_FORGE_AGENT_IMAGE is not set, we are likely running a package build, so package_type should be "PACKAGE"
+        assert_output --partial "package_type=PACKAGE"
+    else
+        # If TELEMETRY_FORGE_AGENT_IMAGE is set, we are likely running a container build, so package_type should be "CONTAINER"
+        assert_output --partial "package_type=CONTAINER"
+    fi
+    
+    if [[ "$(uname -s)" == "Darwin" ]]; then
+        # If we are running on macOS, os should be set to "macos"
+        assert_output --partial "os=macos"
+    elif [[ "$(uname -s)" == "Linux" ]]; then
+        # If we are running on Linux, os should be set to "linux"
+        assert_output --partial "os=linux"
+    else
+        # Windows
+        assert_output --partial "os=windows"
+    fi
+
+    # Version should be passed in to verify directly
+    assert_output --partial "version=${TELEMETRY_FORGE_AGENT_VERSION}"
+}

From 50eb63520fffc4ab17f73406f632e8513bb46ec2 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:37:01 +0100
Subject: [PATCH 08/14] fix: add missing cmake vars

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 Dockerfile.ubi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Dockerfile.ubi b/Dockerfile.ubi
index 48d8d655..fe34b9ad 100644
--- a/Dockerfile.ubi
+++ b/Dockerfile.ubi
@@ -97,6 +97,8 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \
     -DFLB_TESTS_RUNTIME=Off \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DTELEMETRY_FORGE_AGENT_VERSION="$TELEMETRY_FORGE_AGENT_VERSION" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     -DFLB_LOG_NO_CONTROL_CHARS=On \
     -DFLB_CORO_STACK_SIZE=131072 \
     -DFLB_PREFER_SYSTEM_LIB_ZSTD=On \

From 54acd9b4b49b079231174f7c031fd0450060de39 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:44:27 +0100
Subject: [PATCH 09/14] fix: add missing cmake vars

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/packaging/distros/almalinux/Dockerfile   | 7 +++++++
 source/packaging/distros/amazonlinux/Dockerfile | 7 +++++++
 source/packaging/distros/azurelinux/Dockerfile  | 7 +++++++
 source/packaging/distros/centos/6/Dockerfile    | 7 +++++++
 source/packaging/distros/centos/7/Dockerfile    | 7 +++++++
 source/packaging/distros/centos/Dockerfile      | 7 +++++++
 source/packaging/distros/debian/Dockerfile      | 7 +++----
 source/packaging/distros/mariner/Dockerfile     | 7 +++++++
 source/packaging/distros/rockylinux/Dockerfile  | 7 +++++++
 source/packaging/distros/suse/Dockerfile        | 7 +++++++
 source/packaging/distros/ubuntu/Dockerfile      | 7 +++++++
 11 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/source/packaging/distros/almalinux/Dockerfile b/source/packaging/distros/almalinux/Dockerfile
index 616e33a9..fcf86a5e 100644
--- a/source/packaging/distros/almalinux/Dockerfile
+++ b/source/packaging/distros/almalinux/Dockerfile
@@ -133,6 +133,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -148,6 +153,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/amazonlinux/Dockerfile b/source/packaging/distros/amazonlinux/Dockerfile
index f1050155..5ad6f5c0 100644
--- a/source/packaging/distros/amazonlinux/Dockerfile
+++ b/source/packaging/distros/amazonlinux/Dockerfile
@@ -128,6 +128,11 @@ ENV PATH="${CMAKE_HOME}/bin:${PATH}"
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -144,6 +149,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="${TELEMETRY_FORGE_AGENT_DISTRO}" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/azurelinux/Dockerfile b/source/packaging/distros/azurelinux/Dockerfile
index 4772b901..1128896d 100644
--- a/source/packaging/distros/azurelinux/Dockerfile
+++ b/source/packaging/distros/azurelinux/Dockerfile
@@ -44,6 +44,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER as builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -61,6 +66,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/centos/6/Dockerfile b/source/packaging/distros/centos/6/Dockerfile
index 508521a7..4edea7cf 100644
--- a/source/packaging/distros/centos/6/Dockerfile
+++ b/source/packaging/distros/centos/6/Dockerfile
@@ -113,6 +113,11 @@ ARG BASE_BUILDER
 # hadolint ignore=DL3006
 FROM ${BASE_BUILDER} AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -142,6 +147,8 @@ RUN PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CON
         -DFLB_CPACK_SYSVINIT="${FLB_CPACK_SYSVINIT}" \
         -DFLB_UNICODE_ENCODER="${FLB_UNICODE_ENCODER}" \
         -DFLB_PROCESSOR_DEDUP="${FLB_PROCESSOR_DEDUP}" \
+        -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+        -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
         -DOPENSSL_ROOT_DIR=/openssl/openssl-3.5.2 \
         -DOPENSSL_USE_STATIC_LIBS=On \
         -DLIBSSH2_USE_STATIC_LIBS=On \
diff --git a/source/packaging/distros/centos/7/Dockerfile b/source/packaging/distros/centos/7/Dockerfile
index 39939495..75383210 100644
--- a/source/packaging/distros/centos/7/Dockerfile
+++ b/source/packaging/distros/centos/7/Dockerfile
@@ -91,6 +91,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 # We need a more recent OpenSSL as well so build from source
 ADD https://github.com/openssl/openssl/releases/download/openssl-3.5.2/openssl-3.5.2.tar.gz /openssl/
 RUN tar -xzvf /openssl/openssl-3.5.2.tar.gz -C /openssl
@@ -116,6 +121,8 @@ RUN PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CON
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
     -DOPENSSL_ROOT_DIR=/openssl/openssl-3.5.2 \
     -DOPENSSL_USE_STATIC_LIBS=On \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/centos/Dockerfile b/source/packaging/distros/centos/Dockerfile
index 97828b4f..19ff1de3 100644
--- a/source/packaging/distros/centos/Dockerfile
+++ b/source/packaging/distros/centos/Dockerfile
@@ -217,6 +217,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -233,6 +238,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/debian/Dockerfile b/source/packaging/distros/debian/Dockerfile
index 37102e31..d54b79bd 100644
--- a/source/packaging/distros/debian/Dockerfile
+++ b/source/packaging/distros/debian/Dockerfile
@@ -266,15 +266,14 @@ ENV PATH="${CMAKE_HOME}/bin:${PATH}"
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
-ARG FLB_NIGHTLY_BUILD
-ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
-
 ARG TELEMETRY_FORGE_AGENT_DISTRO
 ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
-
 ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
 ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
 
+ARG FLB_NIGHTLY_BUILD
+ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
+
 # Docker context must be the base of the repo
 WORKDIR /tmp/fluent-bit/
 COPY . ./
diff --git a/source/packaging/distros/mariner/Dockerfile b/source/packaging/distros/mariner/Dockerfile
index c4e25f4e..0dd8c8a9 100644
--- a/source/packaging/distros/mariner/Dockerfile
+++ b/source/packaging/distros/mariner/Dockerfile
@@ -46,6 +46,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER as builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -63,6 +68,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/rockylinux/Dockerfile b/source/packaging/distros/rockylinux/Dockerfile
index 7ca5a65e..db0d789b 100644
--- a/source/packaging/distros/rockylinux/Dockerfile
+++ b/source/packaging/distros/rockylinux/Dockerfile
@@ -129,6 +129,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -145,6 +150,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/suse/Dockerfile b/source/packaging/distros/suse/Dockerfile
index 842071fd..b9ff5f67 100644
--- a/source/packaging/distros/suse/Dockerfile
+++ b/source/packaging/distros/suse/Dockerfile
@@ -66,6 +66,11 @@ ENV FLB_JEMALLOC_OPTIONS=$FLB_JEMALLOC_OPTIONS
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER as builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG CMAKE_VERSION
 RUN CMAKE_ARCH=$(uname -m); \
     curl --output /tmp/cmake.sh -L "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$CMAKE_ARCH.sh" && \
@@ -94,6 +99,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]
diff --git a/source/packaging/distros/ubuntu/Dockerfile b/source/packaging/distros/ubuntu/Dockerfile
index 088d589f..8b907e85 100644
--- a/source/packaging/distros/ubuntu/Dockerfile
+++ b/source/packaging/distros/ubuntu/Dockerfile
@@ -360,6 +360,11 @@ ENV PATH="${CMAKE_HOME}/bin:${PATH}"
 # hadolint ignore=DL3006
 FROM $BASE_BUILDER AS builder
 
+ARG TELEMETRY_FORGE_AGENT_DISTRO
+ENV TELEMETRY_FORGE_AGENT_DISTRO=$TELEMETRY_FORGE_AGENT_DISTRO
+ARG TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+ENV TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE
+
 ARG FLB_NIGHTLY_BUILD
 ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
 
@@ -378,6 +383,8 @@ RUN cmake -DCMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" \
     -DCMAKE_INSTALL_SYSCONFDIR="$CMAKE_INSTALL_SYSCONFDIR" \
     -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \
     -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \
+    -DTELEMETRY_FORGE_AGENT_DISTRO="$TELEMETRY_FORGE_AGENT_DISTRO" \
+    -DTELEMETRY_FORGE_AGENT_PACKAGE_TYPE="$TELEMETRY_FORGE_AGENT_PACKAGE_TYPE" \
     ../
 
 VOLUME [ "/output" ]

From f7833a6743caf0f31761dd17e9b2bb12f6f896df Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:53:24 +0100
Subject: [PATCH 10/14] test: fix output checks

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 build-and-test-container.sh                      |  5 +++++
 .../functional/common/verify-environment.bats    | 16 ++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/build-and-test-container.sh b/build-and-test-container.sh
index 284f92dd..8add4513 100755
--- a/build-and-test-container.sh
+++ b/build-and-test-container.sh
@@ -30,4 +30,9 @@ ${CONTAINER_RUNTIME:-docker} build --target=production \
   -t "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}" \
   -f "$SCRIPT_DIR/$DOCKERFILE" "$SCRIPT_DIR/"
 
+${CONTAINER_RUNTIME:-docker} build --target=test \
+  -t "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}-test" \
+  -f "$SCRIPT_DIR/$DOCKERFILE" "$SCRIPT_DIR/"
+
+docker run --rm -t "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}-test"
 "$SCRIPT_DIR"/testing/bats/run-container-integration-tests.sh
diff --git a/testing/bats/tests/functional/common/verify-environment.bats b/testing/bats/tests/functional/common/verify-environment.bats
index b25c10ab..32507953 100644
--- a/testing/bats/tests/functional/common/verify-environment.bats
+++ b/testing/bats/tests/functional/common/verify-environment.bats
@@ -45,27 +45,27 @@ load "$BATS_FILE_ROOT/load.bash"
     # We can assert on the output to check that the env vars are set and have correct values. We will check that distro, package_type, version and os are all present in the output with expected values.
 
     # distro should be set to a value like "ubuntu/latest" or "amazonlinux/2023" plus macos/windows variants so we can just check that it is set to some value and not empty
-    assert_output --partial "distro="
+    assert_output --partial '"distro"=>"'
 
     if [ -z "${TELEMETRY_FORGE_AGENT_IMAGE:-}" ]; then
         # If TELEMETRY_FORGE_AGENT_IMAGE is not set, we are likely running a package build, so package_type should be "PACKAGE"
-        assert_output --partial "package_type=PACKAGE"
+        assert_output --partial '"package_type"=>"PACKAGE"'
     else
         # If TELEMETRY_FORGE_AGENT_IMAGE is set, we are likely running a container build, so package_type should be "CONTAINER"
-        assert_output --partial "package_type=CONTAINER"
+        assert_output --partial '"package_type"=>"CONTAINER"'
     fi
-    
+
     if [[ "$(uname -s)" == "Darwin" ]]; then
         # If we are running on macOS, os should be set to "macos"
-        assert_output --partial "os=macos"
+        assert_output --partial '"os"=>"macos"'
     elif [[ "$(uname -s)" == "Linux" ]]; then
         # If we are running on Linux, os should be set to "linux"
-        assert_output --partial "os=linux"
+        assert_output --partial '"os"=>"linux"'
     else
         # Windows
-        assert_output --partial "os=windows"
+        assert_output --partial '"os"=>"windows"'
     fi
 
     # Version should be passed in to verify directly
-    assert_output --partial "version=${TELEMETRY_FORGE_AGENT_VERSION}"
+    assert_output --partial '"version"=>"'"${TELEMETRY_FORGE_AGENT_VERSION}"'"'
 }

From 793f382d93822b621f457444fda06bb2ab2163da Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 11 Jun 2026 16:57:14 +0100
Subject: [PATCH 11/14] test: remove help check as not valid

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 .../tests/functional/common/verify-environment.bats    | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/testing/bats/tests/functional/common/verify-environment.bats b/testing/bats/tests/functional/common/verify-environment.bats
index 32507953..7bb65c11 100644
--- a/testing/bats/tests/functional/common/verify-environment.bats
+++ b/testing/bats/tests/functional/common/verify-environment.bats
@@ -10,16 +10,6 @@ load "$BATS_FILE_ROOT/load.bash"
 
 # bats file_tags=functional
 
-@test "verify preset env vars are always set" {
-    run "$FLUENT_BIT_BINARY" --help
-    assert_success
-
-    # Check that the env vars are set
-    assert_output --partial 'TELEMETRY_FORGE_AGENT_DISTRO'
-    assert_output --partial 'TELEMETRY_FORGE_AGENT_PACKAGE_TYPE'
-    assert_output --partial 'TELEMETRY_FORGE_AGENT_VERSION'
-}
-
 @test "verify preset env vars have correct values" {
     # We run Fluent Bit with a dummy input that uses the env vars in the config to ensure they are set and have correct values.
     # This will also use a stdout output plugin to print out the dummy record which will contain the env vars in the output, allowing us to assert on their values.

From 175e7bf356c839ee457e72394f9c0f46ac500c74 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Fri, 12 Jun 2026 07:49:37 +0100
Subject: [PATCH 12/14] feat: add TF flags to help

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 build-and-test-container.sh                            |  2 +-
 source/include/fluent-bit/flb_info.h.in                |  4 ++++
 source/src/fluent-bit.c                                |  9 +++++++++
 .../tests/functional/common/verify-environment.bats    | 10 ++++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/build-and-test-container.sh b/build-and-test-container.sh
index 8add4513..aa077ca6 100755
--- a/build-and-test-container.sh
+++ b/build-and-test-container.sh
@@ -34,5 +34,5 @@ ${CONTAINER_RUNTIME:-docker} build --target=test \
   -t "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}-test" \
   -f "$SCRIPT_DIR/$DOCKERFILE" "$SCRIPT_DIR/"
 
-docker run --rm -t "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}-test"
+docker run --rm -t -e TELEMETRY_FORGE_AGENT_IMAGE="${TELEMETRY_FORGE_AGENT_IMAGE}" -e TELEMETRY_FORGE_AGENT_TAG="${TELEMETRY_FORGE_AGENT_TAG}" "${TELEMETRY_FORGE_AGENT_IMAGE}:${TELEMETRY_FORGE_AGENT_TAG}-test"
 "$SCRIPT_DIR"/testing/bats/run-container-integration-tests.sh
diff --git a/source/include/fluent-bit/flb_info.h.in b/source/include/fluent-bit/flb_info.h.in
index 01b6185f..83d04d8d 100644
--- a/source/include/fluent-bit/flb_info.h.in
+++ b/source/include/fluent-bit/flb_info.h.in
@@ -29,4 +29,8 @@
 @FLB_BUILD_FLAGS@
 
 #define FLB_INFO_FLAGS "@FLB_INFO_FLAGS@"
+
+#define TELEMETRY_FORGE_AGENT_VERSION_FLAG "@TELEMETRY_FORGE_AGENT_VERSION@"
+#define TELEMETRY_FORGE_AGENT_DISTRO_FLAG "@TELEMETRY_FORGE_AGENT_DISTRO@"
+#define TELEMETRY_FORGE_AGENT_PACKAGE_TYPE_FLAG "@TELEMETRY_FORGE_AGENT_PACKAGE_TYPE@"
 #endif
diff --git a/source/src/fluent-bit.c b/source/src/fluent-bit.c
index ac99bb2e..ea823e8c 100644
--- a/source/src/fluent-bit.c
+++ b/source/src/fluent-bit.c
@@ -191,6 +191,15 @@ static void flb_help(int rc, struct flb_config *config)
     printf("\n%sInternal%s\n", ANSI_BOLD, ANSI_RESET);
     printf(" Event Loop  = %s\n", mk_event_backend());
     printf(" Build Flags =%s\n", FLB_INFO_FLAGS);
+
+    /*
+     * Print out any custom TF agent info we have.
+     */
+    printf("\n%sTelemetry Forge Agent%s\n", ANSI_BOLD, ANSI_RESET);
+    printf(" Distro  =%s\n", TELEMETRY_FORGE_AGENT_DISTRO_FLAG);
+    printf(" Package =%s\n", TELEMETRY_FORGE_AGENT_PACKAGE_TYPE_FLAG);
+    printf(" Version =%s\n", TELEMETRY_FORGE_AGENT_VERSION_FLAG);
+
     exit(rc);
 }
 
diff --git a/testing/bats/tests/functional/common/verify-environment.bats b/testing/bats/tests/functional/common/verify-environment.bats
index 7bb65c11..9e25c3f7 100644
--- a/testing/bats/tests/functional/common/verify-environment.bats
+++ b/testing/bats/tests/functional/common/verify-environment.bats
@@ -10,6 +10,16 @@ load "$BATS_FILE_ROOT/load.bash"
 
 # bats file_tags=functional
 
+@test "verify preset env vars are always set" {
+    run "$FLUENT_BIT_BINARY" --help
+    assert_success
+
+    # Check that the env vars are set
+    assert_output --partial 'Distro  ='
+    assert_output --partial 'Package ='
+    assert_output --partial "Version =${TELEMETRY_FORGE_AGENT_VERSION}"
+}
+
 @test "verify preset env vars have correct values" {
     # We run Fluent Bit with a dummy input that uses the env vars in the config to ensure they are set and have correct values.
     # This will also use a stdout output plugin to print out the dummy record which will contain the env vars in the output, allowing us to assert on their values.

From a006ff3d0cf381b301ebe915b0df8177f336a47a Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 25 Jun 2026 10:01:40 +0100
Subject: [PATCH 13/14] refactor: shorten env names

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 source/src/flb_env.c        | 38 +++++++++++------------
 source/tests/internal/env.c | 60 ++++++++++++++++++-------------------
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/source/src/flb_env.c b/source/src/flb_env.c
index eba44aa0..62324f4d 100644
--- a/source/src/flb_env.c
+++ b/source/src/flb_env.c
@@ -87,44 +87,44 @@ static int env_preset(struct flb_env *env)
 #endif
     }
 
-    /*
-     * ${TELEMETRY_FORGE_AGENT_DISTRO} this variable is useful to identify the distribution
-     * where the agent is running, if it is not set, we will set it based on build metadata.
-     * This is especially useful for Linux, where we have multiple distros and
-     * we want to be able to identify them.
-     */
-    buf = getenv("TELEMETRY_FORGE_AGENT_DISTRO");
+        /*
+         * ${AGENT_DISTRO} is a short runtime environment variable with distro metadata.
+         * If it is not set, we derive the value from build metadata.
+        * This is especially useful for Linux, where we have multiple distros and
+        * we want to be able to identify them.
+         */
+        buf = getenv("AGENT_DISTRO");
     if (!buf) {
 #if defined(TELEMETRY_FORGE_AGENT_DISTRO)
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_DISTRO", TOSTRING(TELEMETRY_FORGE_AGENT_DISTRO));
+        flb_env_set(env, "AGENT_DISTRO", TOSTRING(TELEMETRY_FORGE_AGENT_DISTRO));
 #else
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_DISTRO", "unknown");
+        flb_env_set(env, "AGENT_DISTRO", "unknown");
 #endif
     }
 
     /*
-     * ${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE} this variable is useful to identify the package type
-     * of the agent, if it is not set, we will set it based on build metadata .
+         * ${AGENT_PACKAGE_TYPE} is a short runtime environment variable with package metadata.
+         * If it is not set, we derive the value from build metadata.
      */
-    buf = getenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+        buf = getenv("AGENT_PACKAGE_TYPE");
     if (!buf) {
 #if defined(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE)
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", TOSTRING(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE));
+        flb_env_set(env, "AGENT_PACKAGE_TYPE", TOSTRING(TELEMETRY_FORGE_AGENT_PACKAGE_TYPE));
 #else
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", "unknown");
+        flb_env_set(env, "AGENT_PACKAGE_TYPE", "unknown");
 #endif
     }
 
     /*
-     * ${TELEMETRY_FORGE_AGENT_VERSION} this variable is useful to identify the version
-     * of the agent, if it is not set, we will set it based on build metadata .
+         * ${AGENT_VERSION} is a short runtime environment variable with version metadata.
+         * If it is not set, we derive the value from build metadata.
      */
-    buf = getenv("TELEMETRY_FORGE_AGENT_VERSION");
+        buf = getenv("AGENT_VERSION");
     if (!buf) {
 #if defined(TELEMETRY_FORGE_AGENT_VERSION)
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_VERSION", TOSTRING(TELEMETRY_FORGE_AGENT_VERSION));
+        flb_env_set(env, "AGENT_VERSION", TOSTRING(TELEMETRY_FORGE_AGENT_VERSION));
 #else
-        flb_env_set(env, "TELEMETRY_FORGE_AGENT_VERSION", "unknown");
+        flb_env_set(env, "AGENT_VERSION", "unknown");
 #endif
     }
 
diff --git a/source/tests/internal/env.c b/source/tests/internal/env.c
index cc5f185f..42fde052 100644
--- a/source/tests/internal/env.c
+++ b/source/tests/internal/env.c
@@ -104,23 +104,23 @@ void test_preset_env_defaults()
         exit(1);
     }
 
-    agent_distro = flb_env_get(env, "TELEMETRY_FORGE_AGENT_DISTRO");
+    agent_distro = flb_env_get(env, "AGENT_DISTRO");
     if (!TEST_CHECK(agent_distro != NULL && strcmp(agent_distro, expected_agent_distro()) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_DISTRO mismatch. Got=%s expect=%s", agent_distro, expected_agent_distro());
+        TEST_MSG("AGENT_DISTRO mismatch. Got=%s expect=%s", agent_distro, expected_agent_distro());
         flb_env_destroy(env);
         exit(1);
     }
 
-    agent_package_type = flb_env_get(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    agent_package_type = flb_env_get(env, "AGENT_PACKAGE_TYPE");
     if (!TEST_CHECK(agent_package_type != NULL && strcmp(agent_package_type, expected_agent_package_type()) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE mismatch. Got=%s expect=%s", agent_package_type, expected_agent_package_type());
+        TEST_MSG("AGENT_PACKAGE_TYPE mismatch. Got=%s expect=%s", agent_package_type, expected_agent_package_type());
         flb_env_destroy(env);
         exit(1);
     }
 
-    agent_version = flb_env_get(env, "TELEMETRY_FORGE_AGENT_VERSION");
+    agent_version = flb_env_get(env, "AGENT_VERSION");
     if (!TEST_CHECK(agent_version != NULL && strcmp(agent_version, expected_agent_version()) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_VERSION mismatch. Got=%s expect=%s", agent_version, expected_agent_version());
+        TEST_MSG("AGENT_VERSION mismatch. Got=%s expect=%s", agent_version, expected_agent_version());
         flb_env_destroy(env);
         exit(1);
     }
@@ -150,9 +150,9 @@ void test_preset_env_overrides()
 
     snprintf(hostname_arg, sizeof(hostname_arg), "HOSTNAME=%s", override_hostname);
     snprintf(os_type_arg, sizeof(os_type_arg), "OS_TYPE=%s", override_os_type);
-    snprintf(agent_distro_arg, sizeof(agent_distro_arg), "TELEMETRY_FORGE_AGENT_DISTRO=%s", override_agent_distro);
-    snprintf(agent_package_type_arg, sizeof(agent_package_type_arg), "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=%s", override_agent_package_type);
-    snprintf(agent_version_arg, sizeof(agent_version_arg), "TELEMETRY_FORGE_AGENT_VERSION=%s", override_agent_version);
+    snprintf(agent_distro_arg, sizeof(agent_distro_arg), "AGENT_DISTRO=%s", override_agent_distro);
+    snprintf(agent_package_type_arg, sizeof(agent_package_type_arg), "AGENT_PACKAGE_TYPE=%s", override_agent_package_type);
+    snprintf(agent_version_arg, sizeof(agent_version_arg), "AGENT_VERSION=%s", override_agent_version);
 
 #if defined(FLB_SYSTEM_WINDOWS)
     ret = _putenv(hostname_arg);
@@ -169,19 +169,19 @@ void test_preset_env_overrides()
 
     ret = _putenv(agent_distro_arg);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_DISTRO failed");
+        TEST_MSG("_putenv AGENT_DISTRO failed");
         exit(1);
     }
 
     ret = _putenv(agent_package_type_arg);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_PACKAGE_TYPE failed");
+        TEST_MSG("_putenv AGENT_PACKAGE_TYPE failed");
         exit(1);
     }
 
     ret = _putenv(agent_version_arg);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("_putenv TELEMETRY_FORGE_AGENT_VERSION failed");
+        TEST_MSG("_putenv AGENT_VERSION failed");
         exit(1);
     }
 #else
@@ -197,21 +197,21 @@ void test_preset_env_overrides()
         exit(1);
     }
 
-    ret = setenv("TELEMETRY_FORGE_AGENT_DISTRO", override_agent_distro, 1);
+    ret = setenv("AGENT_DISTRO", override_agent_distro, 1);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_DISTRO failed");
+        TEST_MSG("setenv AGENT_DISTRO failed");
         exit(1);
     }
 
-    ret = setenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE", override_agent_package_type, 1);
+    ret = setenv("AGENT_PACKAGE_TYPE", override_agent_package_type, 1);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_PACKAGE_TYPE failed");
+        TEST_MSG("setenv AGENT_PACKAGE_TYPE failed");
         exit(1);
     }
 
-    ret = setenv("TELEMETRY_FORGE_AGENT_VERSION", override_agent_version, 1);
+    ret = setenv("AGENT_VERSION", override_agent_version, 1);
     if (!TEST_CHECK(ret == 0)) {
-        TEST_MSG("setenv TELEMETRY_FORGE_AGENT_VERSION failed");
+        TEST_MSG("setenv AGENT_VERSION failed");
         exit(1);
     }
 #endif
@@ -236,23 +236,23 @@ void test_preset_env_overrides()
         exit(1);
     }
 
-    agent_distro = flb_env_get(env, "TELEMETRY_FORGE_AGENT_DISTRO");
+    agent_distro = flb_env_get(env, "AGENT_DISTRO");
     if (!TEST_CHECK(agent_distro != NULL && strcmp(agent_distro, override_agent_distro) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_DISTRO override lost. Got=%s expect=%s", agent_distro, override_agent_distro);
+        TEST_MSG("AGENT_DISTRO override lost. Got=%s expect=%s", agent_distro, override_agent_distro);
         flb_env_destroy(env);
         exit(1);
     }
 
-    agent_package_type = flb_env_get(env, "TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
+    agent_package_type = flb_env_get(env, "AGENT_PACKAGE_TYPE");
     if (!TEST_CHECK(agent_package_type != NULL && strcmp(agent_package_type, override_agent_package_type) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE override lost. Got=%s expect=%s", agent_package_type, override_agent_package_type);
+        TEST_MSG("AGENT_PACKAGE_TYPE override lost. Got=%s expect=%s", agent_package_type, override_agent_package_type);
         flb_env_destroy(env);
         exit(1);
     }
 
-    agent_version = flb_env_get(env, "TELEMETRY_FORGE_AGENT_VERSION");
+    agent_version = flb_env_get(env, "AGENT_VERSION");
     if (!TEST_CHECK(agent_version != NULL && strcmp(agent_version, override_agent_version) == 0)) {
-        TEST_MSG("TELEMETRY_FORGE_AGENT_VERSION override lost. Got=%s expect=%s", agent_version, override_agent_version);
+        TEST_MSG("AGENT_VERSION override lost. Got=%s expect=%s", agent_version, override_agent_version);
         flb_env_destroy(env);
         exit(1);
     }
@@ -262,15 +262,15 @@ void test_preset_env_overrides()
 #if defined(FLB_SYSTEM_WINDOWS)
     _putenv("HOSTNAME=");
     _putenv("OS_TYPE=");
-    _putenv("TELEMETRY_FORGE_AGENT_DISTRO=");
-    _putenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE=");
-    _putenv("TELEMETRY_FORGE_AGENT_VERSION=");
+    _putenv("AGENT_DISTRO=");
+    _putenv("AGENT_PACKAGE_TYPE=");
+    _putenv("AGENT_VERSION=");
 #else
     unsetenv("HOSTNAME");
     unsetenv("OS_TYPE");
-    unsetenv("TELEMETRY_FORGE_AGENT_DISTRO");
-    unsetenv("TELEMETRY_FORGE_AGENT_PACKAGE_TYPE");
-    unsetenv("TELEMETRY_FORGE_AGENT_VERSION");
+    unsetenv("AGENT_DISTRO");
+    unsetenv("AGENT_PACKAGE_TYPE");
+    unsetenv("AGENT_VERSION");
 #endif
 }
 

From b218e0f5b0ddb81ecf26f48d0cff2fec407f7430 Mon Sep 17 00:00:00 2001
From: Patrick Stephens <pat@telemetryforge.io>
Date: Thu, 25 Jun 2026 10:40:00 +0100
Subject: [PATCH 14/14] test: update integration test

Signed-off-by: Patrick Stephens <pat@telemetryforge.io>
---
 .../functional/common/resources/environment-fluent-bit.yaml     | 2 +-
 testing/bats/tests/functional/common/verify-environment.bats    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml b/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
index 8a628596..82044635 100644
--- a/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
+++ b/testing/bats/tests/functional/common/resources/environment-fluent-bit.yaml
@@ -7,7 +7,7 @@ pipeline:
   inputs:
     - name: dummy
       # We use the environment variables to verify that they are set correctly based on the build and packaging configuration of the agent.
-      dummy: '{"distro": "${TELEMETRY_FORGE_AGENT_DISTRO}", "package_type": "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}", "version": "${TELEMETRY_FORGE_AGENT_VERSION}", "os": "${OS_TYPE}"}'
+      dummy: '{"distro": "${AGENT_DISTRO}", "package_type": "${AGENT_PACKAGE_TYPE}", "version": "${AGENT_VERSION}", "os": "${OS_TYPE}"}'
       alias: input_dummy
 
   outputs:
diff --git a/testing/bats/tests/functional/common/verify-environment.bats b/testing/bats/tests/functional/common/verify-environment.bats
index 9e25c3f7..c84a5d04 100644
--- a/testing/bats/tests/functional/common/verify-environment.bats
+++ b/testing/bats/tests/functional/common/verify-environment.bats
@@ -36,7 +36,7 @@ load "$BATS_FILE_ROOT/load.bash"
     assert_success
     refute_output --partial "[error]"
 
-    # The input string is '{"distro": "${TELEMETRY_FORGE_AGENT_DISTRO}", "package_type": "${TELEMETRY_FORGE_AGENT_PACKAGE_TYPE}", "version": "${TELEMETRY_FORGE_AGENT_VERSION}", "os": "${OS_TYPE}"}'
+    # The input string is '{"distro": "${AGENT_DISTRO}", "package_type": "${AGENT_PACKAGE_TYPE}", "version": "${AGENT_VERSION}", "os": "${OS_TYPE}"}'
     # distro will be set to a value like "ubuntu/latest" or "amazonlinux/2023"
     # package_type will be set to "PACKAGE" or "CONTAINER"
     # version will be set to the agent version like "0.1.0"
