opentelemetry-operator icon indicating copy to clipboard operation
opentelemetry-operator copied to clipboard

Env variable substitution not working when using target allocator and custom scrape-config

Open cmergenthaler opened this issue 2 years ago • 4 comments

Component(s)

collector, target allocator

What happened?

Description

When using target allocator together with custom scrape configs, env variable substitution on the collector does not seem to work properly.

Steps to Reproduce

  • Having a remote prometheus metrics endpoint, which should be scraped by custom scrape-config
  • Scrape target in otel-collector is configured using env variables
  • Env variables are set on otel-collector and target-allocator
receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: remotepromendpoint
          scheme: https
          basic_auth:
            username: "${env::USER_ENV}"
            password_file: /etc/my-mounted-password
          tls_config:
            insecure_skip_verify: true
          static_configs:
            - targets: [ "${env::URL_ENV}" ]

Expected Result

Env variables are substituted by otel-collector and/or target-allocator

Actual Result

Otel-collector tries to scrape https://${env::URL_ENV}/metrics

Kubernetes Version

1.26.6

Operator version

0.85.0

Collector version

0.85.0

Environment information

No response

Log output

No response

Additional context

No response

cmergenthaler avatar Oct 23 '23 12:10 cmergenthaler

@anunarapureddy any ideas what may be happening here? I have a few theories, but don't have a ton of time to look in to this currently.

jaronoff97 avatar Oct 23 '23 16:10 jaronoff97

@jaronoff97 I can take a look into this issue.

anunarapureddy avatar Oct 24 '23 15:10 anunarapureddy

I am having the same issue, looks like it has been a while since there was any activity here

cole-christensen avatar Oct 16 '24 07:10 cole-christensen

@cole-christensen Can you link your configuration and explain what isn't working? Also share any logs from the operator, collector, target allocator that may be relevant when you get a chance. thank you!

jaronoff97 avatar Oct 16 '24 14:10 jaronoff97

Hi @anunarapureddy @jaronoff97 , Is there any update on how to resolve this?

maithilee25 avatar Feb 06 '25 20:02 maithilee25

Hi @anunarapureddy @jaronoff97 , Is there any update on how to resolve this?

I will take a into this issue this week and provide an update.

anunarapureddy avatar Feb 08 '25 07:02 anunarapureddy

Is there a reason for the double ::? I believe it should be https://${env:URL_ENV}/metrics

atoulme avatar Mar 12 '25 01:03 atoulme

I can confirm this case. From my super newbie side, who should replace the env vars? The target allocator before exposing the value or the collector after reading the value? I mean, can the collector get values from SD that it parses using their own env vars or the target allocator has to expose the config already parsed? (basically, where have to be the env vars placed?)

I've tried setting the env vars in both sides (without success) but I'm willing to take a look to help with this issue once I'm sure about which component should replace the env vars

JorTurFer avatar Jul 28 '25 15:07 JorTurFer