[英]Configure unique name per target in Prometheus Blackbox exporter
[英]Configure basic_auth for Prometheus Target
我的 prometheus.yml 配置文件中static_configs
中的目标之一通过基本身份验证进行保护。 因此,在 Prometheus 目标页面中始终针对该目标显示描述为“连接被拒绝”的错误。
我研究了如何设置 prometheus 以在尝试抓取该特定目标时提供安全凭据,但找不到任何解决方案。 我发现的是如何在文档的scrape_config
部分进行设置。 这对我不起作用,因为我还有其他不受basic_auth
保护的目标。 请帮我解决这个挑战。
关于我的挑战,这是我的.yml
配置的一部分。
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_timeout: 5s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:5000']
labels:
service: 'Auth'
- targets: ['localhost:5090']
labels:
service: 'Approval'
- targets: ['localhost:6211']
labels:
service: 'Credit Assessment'
- targets: ['localhost:6090']
labels:
service: 'Sweep'
- targets: ['localhost:6500']
labels:
我想在@PatientZro 答案中添加更多详细信息。
就我而言,我需要创建另一个作业(如指定的那样),但 basic_auth 需要与 job_name 的缩进级别相同。 请参阅此处的示例。
同样,我的 basic_auth 案例需要一个路径,因为它们没有显示在我的域的根目录中。
下面是一个指定了 API 端点的示例:
- job_name: 'myapp_health_checks'
scrape_interval: 5m
scrape_timeout: 30s
static_configs:
- targets: ['mywebsite.org']
metrics_path: "/api/health"
basic_auth:
username: 'email@username.me'
password: 'cfgqvzjbhnwcomplicatedpasswordwjnqmd'
最好的事物,
为需要身份验证的人创建另一份工作。
所以就在你发布的内容下面,再做一个
- job_name: 'prometheus-basic_auth'
scrape_interval: 5s
scrape_timeout: 5s
static_configs:
- targets: ['localhost:5000']
labels:
service: 'Auth'
basic_auth:
username: foo
password: bar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.