Skip to content

fix: allow OTEL_CONFIG_OVERRIDES env var to replace agent config overrides #132

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 1 commit into from
Dec 10, 2024

Conversation

obs-gh-mattcotter
Copy link
Collaborator

Description

OB-38640 allow OTEL_CONFIG_OVERRIDES env var to replace agent config overrides

This will allow the agent to be fully run with env variables only.

example:

$ OTEL_CONFIG_OVERRIDES=`cat tmp.yml` ./observe-agent config
# ======== computed agent config
host_monitoring:
    enabled: true
    logs:
        enabled: true
        include: []
    metrics:
        host:
            enabled: true
        process:
            enabled: false
observe_url: ""
otelconfigfile: ""
self_monitoring:
    enabled: true
token: ""


# ======== config file /var/folders/y8/v7cyk9611qbg059c0q02vk0w0000gn/T/observe-agent2529970453/otel-config-overrides-4110568018.yaml
processors:
    probabilistic_sampler:
        sampling_percentage: 50
service:
    pipelines:
        logs/forward:
            exporters:
                - debug
            processors:
                - probabilistic_sampler
            receivers:
                - otlp

Checklist

  • Created tests which fail without the change (if possible)
  • Extended the README / documentation, if necessary

if stringData != "" {
// Viper can handle overrides set in the agent config, or passed in as an env var as a JSON string.
// For consistency, we also want to accept an env var as a YAML string.
err := yaml.Unmarshal([]byte(stringData), &overrides)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this handle nested configs correctly? we have a different delimiter :: for nested keys

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://opentelemetry.io/docs/collector/configuration/#override-settings similar to how otel does it (this is because there can be periods within a key name in the config so that overloads '.' as the delimiter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file in this case if full YAML, this was requested here: https://observeinc.slack.com/archives/C06MM0MSHPA/p1730998713772329?thread_ts=1730939763.831879&cid=C06MM0MSHPA

$ cat tmp.yml 
processors:
  probabilistic_sampler:
    sampling_percentage: 50.0

service:
  pipelines:
    logs/forward:
      receivers: [otlp]
      processors: [probabilistic_sampler]
      exporters: [debug]

@obs-gh-alexlew
Copy link
Collaborator

so what's the actual value we provide in this env var? what does cat tmp.yml look like when expanded?

@obs-gh-mattcotter obs-gh-mattcotter force-pushed the OB-38640-otel-override-env branch from 51684ab to 761c42d Compare December 9, 2024 22:48
@obs-gh-mattcotter obs-gh-mattcotter merged commit de78570 into main Dec 10, 2024
8 checks passed
@obs-gh-mattcotter obs-gh-mattcotter deleted the OB-38640-otel-override-env branch December 10, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants