Example for job with multiple targets using basic_auth with different use rNames and passwords.

70 views
Skip to first unread message

PASS IT Consulting GmbH Research

unread,
Mar 13, 2025, 12:28:53 PM3/13/25
to Prometheus Users
Hi, I might not see the obvious, but I wonder how I can create a job with multiple target, which use https and basic authentiation. But every target uses a different username and password.

Up to now my prometheus.yml looks like this

  - job_name: 'my-job'
    scrape_interval: 20s
    static_configs:
      - targets: ['test2.app1']
        labels:  
          environment: test2
      - targets: ['test3.app1']
        labels:  
          environment: test3
    scheme: https
    basic_auth:
      username: my-user
      password: secret

Can I specify the basic_auth values also below each target and overwriting the definition on the job level.
Or is there a special label like __metrics_path__  and I can use relabeling.

As Isaaid I might overlook the obvois, but I could find no information for this situationj

Daz Wilkin

unread,
Mar 13, 2025, 7:36:52 PM3/13/25
to Prometheus Users
I think you need to have a separate `scrape_config` for each unique `basic_auth` pair. 

PASS IT Consulting GmbH Research

unread,
Mar 14, 2025, 3:14:14 AM3/14/25
to Prometheus Users
Thanks for your answer.
This might be the case, but I do not like this solution, because I would like to treat these jobs as the same logical  job.
I.e. I would like to use the job labels to select all the metrics from the different targets.


I know I could achieve this with target-specific label two, but this seams to me more complicated, than it ought to be.
,   

Reply all
Reply to author
Forward
0 new messages