-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is your feature request related to a problem? Please describe.
When using Configuration Environment Variables,
if a variable is NOT SET on otelcol start, the value will be empty and probably break configuration.
Please provide a way to set default values in case ENV variables are not available.
Describe the solution you'd like
Allow definition of a default value if an ENV variable is not set. Via ${VAR:default_value}
, example:
processors:
attributes/example:
actions:
- key: "${DB_KEY:CustomerDefaultKey}"
action: "${OPERATION:CustomerDefaultOperation}"
This mimics the syntax of grafana promtail
Another example is docker-compose
, where "Default values can be defined inline using typical shell syntax"
https://github.com/docker/docker.github.io/blob/db650b4772f605683ba4143d0b0de44d0a187db4/compose/compose-file/index.md#interpolation
${VARIABLE:-default}
evaluates todefault
ifVARIABLE
is unset or
empty in the environment.${VARIABLE-default}
evaluates todefault
only ifVARIABLE
is unset
in the environment.
and more, which is more complex however.
Describe alternatives you've considered
For example, grafana allows to Override configuration with environment variables
For OTEL Collector, this could look like this. Given this configuration file (section):
exporters:
jaeger:
endpoint: my_default_server:14250
Providing an environment variable crafted like so:
export OTELCOL_EXPORTERS_JAEGER_ENDPOINT=some_other_server:23456
Could overwrite the value from default configuration or configuration files.
(Grafana is supporting even more variable substituation ways, but this is certainly overkill for OTEL Collector.)
At the moment, the configuration file (including ENV vars within the file) is the only way to configure OTEL Collector (?), which may be a deliberate design choice. It is not possible to overwrite specific configuration keys by using:
- CLI Flags
- ENV variables directly addressing those keys (so described approach above)
Which is not bad by all means, since mixing all those possiblities creates complex and confusing configuration.
However ENV variables and CLI Flags are easier to use when running OtelCol as a container, in comparison to a config file. When not running on kubernetes opentelemetry-operator is no alternative.