-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support default values for configuration environment variables #5228
Comments
This is wrong, look into "yaml:" provider (https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/mapprovider/yamlmapprovider/mapprovider.go) you can do something like:
Or using the
We will follow the same model as defined by our providers so will be something like |
Is this documented somewhere? This does deserve to be available in user-facing docs. I can write that doc if we have readme files available for all the supported providers. |
Correct me if I am wrong, but the envmapprovider is basically a replacement for file or yaml map providers, i.e you can have a partial or full configuration stored in an environment variable which you can specify in the I believe these are two different provisions. |
We are very close to propose for merging #4742 which will use the same providers also inside the config yaml. |
No, this only means that you can use |
See #2534 (comment) for a workaround It looks like someone did a draft PR at #4458 but it got stalled. |
if they are removed or never included and tested with otel-col-contriub 0.91.0 and 0.72.0
|
@systems1 this seems like a separate issue, can you report this on a new issue and post a full configuration example that reproduces the issue? |
The ticket is 2+ years old, and there is no path forward, #4458 with shell syntax was not accepted. Is the consensus to go with |
@yurishkuro The OpenTelemetry Configuration WG now admits the shell syntax for the SDK configuration files. Since we aim to be aligned with them, it makes sense in my opinion to add support in the Collector for this as well. |
…OTL-2877 is completed and after open-telemetry/opentelemetry-collector#5228
I’d like to bump prioritization for this ticket due to the recent changes introduced in issue #9532. The 9532 change, introduced via a feature gate, breaks my previous usage of optional environment variables in collector configurations. Before #9532: memory_limiter:
check_interval: 2s
limit_mib: ${OTEL_MEMORY_LIMIT_MIB} After #9532:
To work around this, I would like to use default values for configuration environment variables as proposed in this ticket. I would use env var memory_limiter:
check_interval: 2s
limit_mib: ${OTEL_MEMORY_LIMIT_MIB:-512} This will help avoid breaking changes while retaining previous functionality. |
@jvoravong I don't get the same error as you do. With this configuration file: Config file (click to expand)receivers:
nop:
exporters:
nop:
processors:
memory_limiter:
check_interval: 2s
limit_mib: ${OTEL_MEMORY_LIMIT_MIB}
service:
pipelines:
metrics:
receivers: [nop]
exporters: [nop]
processors: [memory_limiter] I get the following error:
Which I believe is the same error you would have gotten before the feature gate. Could you give more details about your setup? Are you using multiple configuration files? Are you using a Helm chart? |
Currently Otle colector yaml file do not support default values like ${OTEL_MEMORY_LIMIT_MIB:-512} Please support default values |
…ry#10907) #### Description Support shell-style default value and error message for env var expansion. ``` // A default value for unset variable can be provided after :- suffix, for example: // `env:NAME_OF_ENVIRONMENT_VARIABLE:-default_value` ``` #### Link to tracking issue Fixes open-telemetry#5228 #### Testing Unit tests #### Documentation * [x] Provider Go docs * [ ] Probably needs some other docs changes? --------- Signed-off-by: Yuri Shkuro <[email protected]>
Highly appreciated feature . Tx a lot @yurishkuro @mx-psi for contributing 👏 |
## Which problem is this PR solving? - Resolves #6027 ## Description of the changes - Leverages the functionality added in open-telemetry/opentelemetry-collector#5228 to remove the logic for rewriting the config and simply setting an environment variable for the Kafka integration tests. ## How was this change tested? - The change is to an integration test so the CI passing is a good test for this change ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Mahad Zaryab <[email protected]>
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: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 orempty in the environment.
${VARIABLE-default}
evaluates todefault
only ifVARIABLE
is unsetin 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):
Providing an environment variable crafted like so:
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:
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.
The text was updated successfully, but these errors were encountered: