Ron*_*ver 13 monitoring prometheus prometheus-blackbox-exporter
我有一个将由 Prometheus 监控的应用程序,但该应用程序需要自定义标头键,例如:
x-auth-token: <customrandomtoken>
Run Code Online (Sandbox Code Playgroud)
我应该如何处理 prometheus.yml?
Prometheus 本身没有办法定义自定义标头以到达导出器。添加该功能的想法在这个 GitHub 问题中进行了讨论。Tl;dr:如果您需要自定义标头,请使用转发代理注入它(我在另一个答案中发布了一个示例)。
该prometheus-blackbox-exporter标签表明问题与制作探针的导出器有关,这是一个单独的东西,并且它确实有一种设置标头的方法。只是,它不会抓取指标,而是会生成指标。
Blackbox 导出器有自己的配置文件,由模块组成。模块是一组参数,定义如何进行探测以及期望的结果。以下是查找 200-299 响应代码并使用标头的模块示例 X-Auth-Token:
modules:
http_2xx_with_header:
prober: http
http:
headers:
X-Auth-Token: skdjfh98732hjf22exampletoken
Run Code Online (Sandbox Code Playgroud)
当您让blackbox导出器加载新配置时,您还需要调整Prometheus配置:
scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx_with_header] # <- Here goes the name of the new module
static_configs:
- targets:
- http://prometheus.io
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11866 次 |
| 最近记录: |