前言
系統預警是一件十分重要的事情,做好系統的監控預警是一件十分有必要的事情;接下來分享一下SpringBoot自帶的健康檢查與監控的配置。
背景
項目類型:SpringBoot項目;
SpringBoot的版本 2.0之前 與 2.0之後是不一樣;
配置
1 引入jar
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2 SpringBoot 2.0使用之前需要配置文件中添加
management.security.enabled=false
使用過程
SpringBoot 2.0 請求服務需要加前綴/actuator,也可以通過添加配置去掉
management:
endpoints:
web:
base-path: /
actuator接口信息如下
postman請求如下
actuator 返回信息解釋
其中UP表示健康
actuator 其他配置
#修改訪問路徑 2.0之前默認是/ 2.0默認是 /actuator 可以通過這個屬性值修改
management.endpoints.web.base-path = /
#開放所有頁面節點 默認只開啓了health、info兩個節點
management.endpoints.web.exposure.include = *
#顯示健康具體信息 默認不會顯示詳細信息
management.endpoint.health.show-details = always
監控進程是否意外停止可以通過通過監控/health或/info節點來判斷進程是否還在,如果沒有會發相關的報警;