服務監控Spring Boot Actuator

(1)添加依賴

我使用的springboot的版本是2.0.5.RELEASE版本spring

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

(2)能夠直接使用的請求

路徑 做用
/autoconfig 獲取應用的自動化配置報告
/beans 獲取應用上下文建立的全部bean
/configprops 獲取應用中配置的屬性信息報告
/env 用來獲取應用全部可用的環境屬性報告。包括環境變量、JVM屬性、應用的配置屬性和命令行中的參數。
/mappings 返回全部Spring MVC的控制器映射關係報告。
/info 返回應用自定義的信息
/metrics 用來返回當前應用的各種重要度量指標,好比內存信息、線程信息、垃圾收集信息等。
/health 獲取應用的各種健康指標信息。
/dump 暴露程序運行中的線程信息。
/trace 返回基本的HTTP跟蹤信息。
/shutdown 關閉應用,經過endpoints.shutdown.enabled=true進行設置。

(3)出現問題

若是在訪問上述端點的時候出現如下問題:安全

Full authentication is required to access actuator endpoints. Consider adding Spring Security or set 'management.security.enabled' to false.

解決方案:在application.properties文件中設置:springboot

endpoints.actuator.enabled=true
endpoints.actuator.sensitive=false
endpoints.beans.sensitive=false
endpoints.beans.enabled=true
endpoints.health.sensitive=false
endpoints.health.enabled=true
#安全驗證
management.security.enabled=false
相關文章
相關標籤/搜索