【发布时间】:2026-01-25 20:05:01
【问题描述】:
我们很少有实现健康检查的 Spring Boot 应用程序。根据@Thiru 的suggestion,这些检查的响应已更改为 JSON 格式。我现在得到以下回复:
Prometheus 服务器正在 Ubuntu 实例上运行。必须监控的 Spring Boot 服务正在 Windows Server 2016 上运行。在看到 this 的帖子后,我在 Windows Server 上安装了 blackbox-exporter(版本 0.12.0.windows-amd64)。
在blackbox.yml 的客户端(IP:172.16.x.yz)的客户端(Windows 服务器)上完成了以下更改:
modules:
http_2xx:
prober: http
http:
http_post_2xx:
prober: http
timeout: 5s
http:
method: POST
headers:
Content-Type: application/json
body: '{"status": "UP"}'
...
...
在Prometheus服务器上,prometheus.yml的内容如下:
...
...
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'blackbox'
metrics_path: /probe
params:
#module: [http_2xx] # Look for a HTTP 200 response.
module: [http_post_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- http://172.16.x.yz:6300/serviceA/actuator/health
- http://172.16.x.yz:6340/serviceB/actuator/health
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 172.16.x.yz:9115 # The blackbox exporter's real hostname:port.
在客户端和服务器上进行上述更改后,当我重新启动 blackbox-exporter 和 prometheus 时,我看到 Prometheus 总是 将 State 显示为 UP,即使这两个服务出口商正在监控下降。似乎 Prometheus 显示的是blackbox-exporter 的状态,而不是服务的状态。有什么建议我可以解决这个问题吗?
【问题讨论】: