From d1b65ed4e177f6a59a078b2d8351d67f0f9a936c Mon Sep 17 00:00:00 2001 From: Matt Cotter Date: Tue, 10 Dec 2024 14:23:12 -0600 Subject: [PATCH] fix: clarify and expand the default env vars the agent provides to the configs --- internal/connections/confighandler.go | 12 +++++++++--- packaging/docker/observe-agent/otel-collector.yaml | 4 ++-- .../linux/etc/observe-agent/otel-collector.yaml | 4 ++-- packaging/macos/config/otel-collector.yaml | 4 ++-- packaging/windows/config/otel-collector.yaml | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/internal/connections/confighandler.go b/internal/connections/confighandler.go index e7dfdde65..31b775a94 100644 --- a/internal/connections/confighandler.go +++ b/internal/connections/confighandler.go @@ -78,13 +78,19 @@ func GetAllOtelConfigFilePaths(ctx context.Context, tmpDir string) ([]string, er func SetEnvVars() error { collector_url, token, debug := viper.GetString("observe_url"), viper.GetString("token"), viper.GetBool("debug") - endpoint, err := url.JoinPath(collector_url, "/v2/otel") + otelEndpoint, err := url.JoinPath(collector_url, "/v2/otel") + if err != nil { + return err + } + promEndpoint, err := url.JoinPath(collector_url, "/v1/prometheus") if err != nil { return err } // Setting values from the Observe agent config as env vars to fill in the OTEL collector config - os.Setenv("OBSERVE_ENDPOINT", endpoint) - os.Setenv("OBSERVE_TOKEN", "Bearer "+token) + os.Setenv("OBSERVE_COLLECTOR_URL", collector_url) + os.Setenv("OBSERVE_OTEL_ENDPOINT", otelEndpoint) + os.Setenv("OBSERVE_PROMETHEUS_ENDPOINT", promEndpoint) + os.Setenv("OBSERVE_AUTHORIZATION_HEADER", "Bearer "+token) os.Setenv("FILESTORAGE_PATH", GetDefaultFilestoragePath()) if debug { diff --git a/packaging/docker/observe-agent/otel-collector.yaml b/packaging/docker/observe-agent/otel-collector.yaml index dab61d38a..887504d97 100644 --- a/packaging/docker/observe-agent/otel-collector.yaml +++ b/packaging/docker/observe-agent/otel-collector.yaml @@ -83,9 +83,9 @@ processors: exporters: otlphttp/observe: - endpoint: ${env:OBSERVE_ENDPOINT} + endpoint: ${env:OBSERVE_OTEL_ENDPOINT} headers: - authorization: ${env:OBSERVE_TOKEN} + authorization: ${env:OBSERVE_AUTHORIZATION_HEADER} sending_queue: num_consumers: 4 queue_size: 100 diff --git a/packaging/linux/etc/observe-agent/otel-collector.yaml b/packaging/linux/etc/observe-agent/otel-collector.yaml index 8685af150..5039c0ce4 100644 --- a/packaging/linux/etc/observe-agent/otel-collector.yaml +++ b/packaging/linux/etc/observe-agent/otel-collector.yaml @@ -83,9 +83,9 @@ processors: exporters: otlphttp/observe: - endpoint: ${env:OBSERVE_ENDPOINT} + endpoint: ${env:OBSERVE_OTEL_ENDPOINT} headers: - authorization: ${env:OBSERVE_TOKEN} + authorization: ${env:OBSERVE_AUTHORIZATION_HEADER} sending_queue: num_consumers: 4 queue_size: 100 diff --git a/packaging/macos/config/otel-collector.yaml b/packaging/macos/config/otel-collector.yaml index 8685af150..5039c0ce4 100644 --- a/packaging/macos/config/otel-collector.yaml +++ b/packaging/macos/config/otel-collector.yaml @@ -83,9 +83,9 @@ processors: exporters: otlphttp/observe: - endpoint: ${env:OBSERVE_ENDPOINT} + endpoint: ${env:OBSERVE_OTEL_ENDPOINT} headers: - authorization: ${env:OBSERVE_TOKEN} + authorization: ${env:OBSERVE_AUTHORIZATION_HEADER} sending_queue: num_consumers: 4 queue_size: 100 diff --git a/packaging/windows/config/otel-collector.yaml b/packaging/windows/config/otel-collector.yaml index 3c88accb3..4fc96e1aa 100644 --- a/packaging/windows/config/otel-collector.yaml +++ b/packaging/windows/config/otel-collector.yaml @@ -63,9 +63,9 @@ processors: exporters: otlphttp/observe: - endpoint: ${env:OBSERVE_ENDPOINT} + endpoint: ${env:OBSERVE_OTEL_ENDPOINT} headers: - authorization: ${env:OBSERVE_TOKEN} + authorization: ${env:OBSERVE_AUTHORIZATION_HEADER} sending_queue: num_consumers: 4 queue_size: 100