SpringBoot中使用actuator监测与度量

  SpringBoot提供了监测与度量的功能,本篇记录一下使用过程

1、添加依赖

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

启动工程,访问 http://localhost:8080/actuator,下面是默认监控的范围(health、info)

  

 2、配置说明

# 指定监控端口,默认与web端口一致
management.server.port=9001

# 指定监控的路径,默认是:/actuator
management.endpoints.web.base-path=/monitor

# 开放所有endpoints(监控范围是所有,不包含shutdown)
management.endpoints.web.exposure.include=*

# 开放/actuator/shutdown
management.endpoint.shutdown.enabled=true

# 显示健康具体信息,默认不会显示详细信息
management.endpoint.health.show-details=always

3、示例如下

  1)监测所有的bean:http://localhost:9001/monitor/beans

  2)监测,磁盘、数据库连接等信息:http://localhost:9001/monitor/health

  3)监测环境信息,包含application.properties里面的属性、值:http://localhost:9001/monitor/env

  4)监测日志信息:http://localhost:9001/monitor/loggers

  5)监测url:http://localhost:9001/monitor/mappings

  6)监测application.properties中info开头的信息:http://localhost:9001/monitor/info

  application.properties中设置:info.aa=aa,info.bb=bb,浏览器访问出现:{aa: "aa",bb: "bb"}

 

posted @ 2019-12-11 21:41  雷雨客  阅读(459)  评论(0)    收藏  举报