代码之家  ›  专栏  ›  技术社区  ›  Technext

为Spring Boot运行状况检查监视配置Prometheus

  •  2
  • Technext  · 技术社区  · 6 年前

    我们几乎没有实现健康检查的Spring引导应用程序。对这些检查的响应根据@Thiru的 suggestion . 我现在得到以下回复:

    enter image description here

    普罗米修斯服务器正在Ubuntu实例上运行。必须监视的Spring引导服务正在Windows server 2016上运行。我已经安装了 黑盒导出程序 (版本 0.12.0.windows-amd64 )在Windows服务器上 this 邮政。

    在客户端(IP为的Windows服务器)上进行了以下更改: 172.16.x.yz )侧入 blackbox.yml :

    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.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 ,我看到普罗米修斯 总是 显示 State 即使出口商正在监控的两项服务都会下跌。似乎普罗米修斯正在展示 黑盒导出程序 不是为了服务。有什么建议可以帮我解决吗?

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  2
  •   Thiru    6 年前

    我建议使用一些有助于将spring health作为prometheus出口商出口的工具。基本上,exporter帮助使用jsonpath将json数据从http url转换为prometheus度量,如:

        2
  •  0
  •   deHaar    5 年前

    在我看来,普罗米修斯的目标实际上表明刮伤目标处于上升或下降状态。这与healthcheck端点状态无关。只能在探测成功度量中检查healthcheck端点状态(1为“上”,0为“下”)。你可以查看下面的截图。 对不起,我英语不好。

    Targets status

    Real Status of endpoint