How to configure Prometheus to bypass proxy for a specific target? (Edited)
I have a prometheus.yml configuration file, and I want my server not to use a proxy, while other targets should be configured to go through a proxy. I tried using proxy_url for specific targets, but it didn’t work.
Here’s my current working configuration (except for the “exceptional” server). How can I exclude this server from using the proxy?
Here’s my configuration:
global: scrape_interval: 15s
scrape_configs: - job_name: 'node'
proxy_url: 'http://127.0.0.1:8888'
static_configs: - targets: ['192.0.2.1:9100'] labels: instance: exceptional - targets: ['www.example.com:9100'] labels: instance: remote1 - targets: ['server2.local:9100'] labels: instance: remote2 - targets: ['203.0.113.10:9100'] labels: instance: peero-1 - targets: ['198.51.100.5:9100'] labels: instance: reerp-2
basic_auth: username: 'prometheus'
Answers
Edward Evans
8 months ago
Rating
Proxy settings can only be defined at the job level, not for individual targets. To exclude the "exceptional" server from using the proxy, you’ll need to split your targets into separate jobs and assign the proxy only to those jobs that require it.
Here’s how you can achieve that:
In this example, I’ve separated the "exceptional" server into a different job without the proxy_url field, which allows it to bypass the proxy while the other targets still go through the proxy.