Skip to content

metrics

liubao edited this page Aug 29, 2022 · 3 revisions

上报监控(metrics)信息

Spring Cloud Huawei使用Spring Cloud Actuator上报监控信息,并增加了很多监控指标,比如服务治理相关的指标。

配置

一般会通过prometheus来上报监控信息。在项目中引入相关依赖:

<dependency>
  <groupId>com.huaweicloud</groupId>
  <artifactId>spring-cloud-starter-huawei-actuator</artifactId>
</dependency>
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

开启 health, prometheus等监控端点, 在 application.yml 中配置:

management:
  endpoint:
    health:
      group:
        readiness:
          include: registry
  endpoints:
    web:
      exposure:
        include: "health,prometheus"
  metrics:
    tags:
      application: ${spring.application.name}

使用

  • 查看健康状态
http://localhost:9094/actuator/health/readiness
http://localhost:9094/actuator/health/liveness
  • 查看监控(metrics) 数据
http://localhost:9094/actuator/prometheus

可以再ServiceStage中使用这些端点,实现灵活的滚动升级,以及往 AOM 上报监控数据。

Clone this wiki locally