prometheus/prometheus

Add proxy_url to targets as meta label

開放

#17,097 建立於 2025年8月28日

 (5 則留言) (0 個反應) (1 位負責人)Go (10,408 個分叉)batch import
component/service discoveryhelp wantedkind/enhancementpriority/P3

倉庫指標

星標
 (64,042 顆星)
PR 合併指標
 (平均合併 11天 5小時) (30 天內合併 118 個 PR)

描述

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.

貢獻者指南