![如何使用 blackbox exporter 监控多个端口?](https://linux22.com/image/1202093/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20blackbox%20exporter%20%E7%9B%91%E6%8E%A7%E5%A4%9A%E4%B8%AA%E7%AB%AF%E5%8F%A3%EF%BC%9F.png)
我正在使用 Prometheus,我需要监控多个端口,但我找不到相关信息。Blackbox 导出器文档不够用,因为它只涉及监控一个端口。
我正在使用 Ubuntu Server。
谢谢
答案1
你可以在target列表中指定端口,以官方的例子为例:
scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- http://prometheus.io # Target to probe with http.
- https://prometheus.io # Target to probe with https.
- http://example.com:8080 # Target to probe with http on port 8080.
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 # Blackbox exporter.
您可以为每个端口指定一个目标,例如:
static_configs:
- targets:
- http://example.com:1234
- http://example.com:4567
- http://example.com:8901
本例使用http_2xx探测,但同样适用于其他探测模块。