SpringBoot工程下的健康检查应用

健康监控简述

Spring Boot 中actuator模块提供了健康检查,审计、指标收集,HTTP跟踪等功能,能够帮助咱们更好的管理和跟踪springboot项目。web

健康监控配置实现

在须要使用健康监控的项目或module中,添加以下依赖:spring

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

添加完依赖之后,reload项目或module。segmentfault

健康监控启动分析

启动项目,在浏览器中输入以下地址:(SpringBoot默认打开的监控选项有限)浏览器

http://localhost/actuator

其访问结果,如图所示:springboot

image.png

还能够在actuator列出的选中中进行点击,例如访问health服务器

http://localhost/actuator/health

其呈现结果,如图所示(其中up状态表示正常):
image.pngapp

假如但愿查看更多actuator选项,能够在spring boot中配置文件spring-boot

application.properties中添加以下语句:spa

management.endpoints.web.exposure.include=*

而后,重启服务器,基于访问http://localhost/actuator地址...)code

总结(Summary)

本小节主要是对springboot工程中的健康监控功能作了一个简易分析和实现,本身能够基于业务的须要,进行监控的配置和分析.

springboot

相关文章
相关标签/搜索