初步认识SpringBoot的Actuator监控服务
SpringBoot的Actuator
在生产环境中,需要实时或定期监控服务的可用性,SpringBoot的actuator功能提供了很多监控所需的接口,actuator是SpringBoot提供的对应系统的自省和监控的集成功能,可以对应用系统进行配置查看,健康检查,相关功能统计等。 如何使用改功能? 在项目中添加依赖
<!--actuator起步依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
在application.properties配置文件中指定监控的HTTP端口,如果指定,则使用和Servlet相同的端口。
# actuator # actuator监控的端口(端口可配可不配) management.server.port=8100 management.server.servlet.context-path=/springbootmybatis # 默认只开启health和info,设置为*,则包含所有web入口端点 management.endpoints.web.exposure.include=*
http://localhost:8100/springbootmybatis/actuator/health
{"status":"UP"}
http://localhost:8100/springbootmybatis/actuator/info
{}
