EDXEnv

Learn about the EDXEnv Edge Delta OTTL extension function.

Minimum Agent Version: v2.5.0

EDXEnv fills a gap in standard OTTL which lacks environment variable access. While OTTL can work with resource attributes and other telemetry data, it cannot access system environment variables at runtime. This Edge Delta extension enables you to inject configuration values, deployment-specific information, or secrets from environment variables into your telemetry data, making pipelines more dynamic and configurable.

Syntax

EDXEnv(env_variable_name, default_value)
  • env_variable_name: The name of the environment variable to retrieve.
  • default_value: The default value to return if the environment variable is not set or is empty (optional).

Input

{
  "_type": "log",
  "timestamp": 1735789700000,
  "body": "Application started",
  "resource": {...},
  "attributes": {
    "app_name": "telemetry-processor",
    "start_time": "2024-01-10T10:00:00Z"
  }
}

Assuming these environment variables are set:

  • ENVIRONMENT=production
  • REGION=us-west-2
  • CLUSTER_NAME=telemetry-cluster-01

Example

set(attributes["environment"], EDXEnv("ENVIRONMENT", "development"))
set(attributes["region"], EDXEnv("REGION", "us-east-1"))
set(attributes["cluster"], EDXEnv("CLUSTER_NAME", "default-cluster"))
set(attributes["debug_mode"], EDXEnv("DEBUG_MODE", "false"))
set(attributes["api_version"], EDXEnv("API_VERSION", "v1"))

Output

{
  "_type": "log",
  "timestamp": 1735789730000,
  "body": "Application started",
  "resource": {...},
  "attributes": {
    "app_name": "telemetry-processor",
    "start_time": "2024-01-10T10:00:00Z",
    "environment": "production",
    "region": "us-west-2",
    "cluster": "telemetry-cluster-01",
    "debug_mode": "false",
    "api_version": "v1"
  }
}

The EDXEnv function has retrieved the values from environment variables where they exist (ENVIRONMENT, REGION, CLUSTER_NAME) and used the provided default values for variables that don’t exist (DEBUG_MODE defaults to “false”, API_VERSION defaults to “v1”).