在生產環境中,須要實時或按期監控服務的可用性,spring-Boot的Actuator 功能提供了不少監控所需的接口。node
Actuator是Spring Boot提供的對應用系統的自省和監控的集成功能,能夠對應用系統進行配置查看、健康檢查、相關功能統計等,通常運維人員使用多些。web
咱們這裏監控03-springboot-web程序spring
<!--Spring Boot Actuator依賴--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
我這裏沒有進行配置json
server.port=8080瀏覽器
server.servlet.context-path=/03-springboot-webspringboot
management.server.port=8100app
management.server.servlet.context-path=/03-springboot-web運維
#默認只開啓了health和info,設置爲*,則包含全部的web入口端點 management.endpoints.web.exposure.include=*
默認沒有內容spring-boot
須要本身在application.properties配置文件中添加信息,須要以info開頭,後面的內容能夠本身設定,通常配置項目的版權等信息,例如url
#配置項目版權相關信息 info.contact.email=bjpowernode@163.com info.contact.phone=010-84846003
配置完畢後,重啓項目再進行訪問
HTTP方法 |
路徑 |
描述 |
GET |
/configprops |
查看配置屬性,包括默認配置 |
GET |
/beans |
查看Spring容器目前初始化的bean及其關係列表 |
GET |
/env |
查看全部環境變量 |
GET |
/mappings |
查看全部url映射 |
GET |
/health |
查看應用健康指標 |
GET |
/info |
查看應用信息 |
GET |
/metrics |
查看應用基本指標 |
GET |
/metrics/{name} |
查看具體指標 |
JMX |
/shutdown |
關閉應用 |
shutdown的使用
注意:/shutdown不能直接在瀏覽器中訪問
# 啓用關閉springboot的服務 management.endpoint.shutdown.enabled=true