依赖
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.6.1</version>
</dependency>
使用http://localhost:8080/actuator
来访问监控功能
http://localhost:8080/actuator/**
后面可以接需要监控的监控端点Endpoint。springboot监控默认有两种模式
● HTTP:默认只暴露health和info
● JMX:默认暴露所有端点
我们可以通过jconsole命令来连接本地应用来监控各个端点的详细信息。但一般是通过http的形式来监控。我们需要通过修改application.yaml文件来实现。
management:
endpoints:
enabled-by-default: true
#默认暴露所有端点
web:
exposure:
include: '*'
#http模式下暴露所有端点
最常用的Endpoint
● Health:健康状况
● Metrics:运行时指标
● Loggers:日志记录
禁用redis的自动配置
endpoint:
health:
show-details: always
#显示health端点的详细信息 默认值为never
开启与禁用:可以通过enable属性来开启指定端点的监控功能
management:
endpoints:
enabled-by-default: false
web:
exposure:
include: '*'
endpoint:</