prometheus/prometheus

Add proxy_url to targets as meta label

Open

#17097 opened on Aug 28, 2025

View on GitHub
 (5 comments) (0 reactions) (1 assignee)Go (64,042 stars) (10,408 forks)batch import
component/service discoveryhelp wantedkind/enhancementpriority/P3

Description

Problem

I'm working in a network topology of several local private networks which are connected to a global network via a host pc. For service discovery of my targets (the one in the privat networks as well as the host pcs) I use http SD. However, using the PushProx, I have to statically configure the proxy_url per job:

- job_name: "example_job"
    proxy_url: http://host_pc:8080
    http_sd_configs:
      - url: "https://example_SD/local_targets"

This doesnt allow me to dynamically configure the proxies depending on the current state of my network topology.

Proposal

If the proxy url would be (also) passed as a meta label, I could add this url to my http SD and relabel it to cinfigure the proxy, something like this:

- job_name: "example_job"
    http_sd_configs:
      - url: "https://example_SD/local_targets"
      relabel_configs:
        - source_labels: [hostpc]
          target_label: __proxy_url
          replacement: 'http://${1}:8080'

My current approach is to write this dynamic part of the yaml with a script but this is of course a bit unconventional and not ideal.

Contributor guide