Spring Boot 监控与管理

Spring Boot 在 Start POMs中提供了一个特殊的依赖模块 spring-boot-start-actuator ,引入改模块能自动为Spring Boot构建应用提供一系列用于监控的端点。

<dependency>
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-start-actuator</artifactId>
</dependency>

 通过这些端点我们可以实时获取应用的各项监控指标:

      比如访问 /health 端点,我们可以获取如下信息;

{
    "status":"UP",
    "diskSpace":{
          "status":"UP",
          "total":"491270",
          "free":"383870",
          "threshold":"10485670"
    }     
}

使用Spring Cloud的各个组件后,他的返回会变得非常丰富,有助于我们定制个性化的监控策略。

根据原生端点的作用,可以将原生端点分为以下三大类:

    应用配置类:例如:/autoconfig 获取应用自动化配置报告。

    度量指标类:/metrics: 各类重要度量指标,比如内存信息,线程信息、垃圾回收信息。

    操作控制类:/shutdown ,在配置文件中开启后,访问应用的/shutdown端点就能实现远程关闭该应用的操作。     

猜你喜欢

转载自www.cnblogs.com/taiguyiba/p/9147505.html