Spring Boot Actuator監控器配置及使用解析
一、簡介
Actuator(激勵者;執行器)是Spring Boot提供的一個可挺拔模塊,用于對工程進行監控。其通過不同的監控終端實現不同的監控功能。其功能與Dubbo的監控中心類似,不同的是,Dubbo的監控中心是需要專門部署的,而Spring Boot的Actuator是存在于每一個工程中的。
二、依賴
隨便一個Spring Boot工程中都可以使用Actuator對其進行監控。
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
三、配置
#-----------------------------------Actuator監控器------------------------------------# Actuator監控端口與控制中心,默認只開啟info、與health監控# http://localhost:9999/actuator/beansmanagement: server: port: 9999 #設置Actuator監控端口 endpoints: web: exposure: include: ’*’ #打開Actuator所有監控 #exclude: [’env’,’beans’] base-path: /actuator #設置Actuator監控基本路徑 #-----------------------------------INFO------------------------------------#自定義INFO信息#瀏覽器訪問 http://localhost:9999/actuator/infoinfo: company: name: ’公司名稱’ url: ’www.xxxx’ addr: ’china’
四、訪問測試
1、beans終端
http://localhost:9999/actuator/beans
2、env
http://localhost:9999/actuator/env
3、自定義信息
五、常用的監控終端
在百度搜索“springboot actuator”即可找到如下表格
HTTP 方法 監控終端 功能描述 GET /autoconfig 提供了一份自動配置報告,記錄哪些自動配置條件通過了,哪些沒通過 GET /configprops 描述配置屬性(包含默認值)如何注入Bean GET /beans 描述應用程序上下文里全部的Bean,以及它們的關系 GET /dump 獲取線程活動的快照 GET /env 獲取全部環境屬性 GET /env/{name} 根據名稱獲取特定的環境屬性值 GET /health 報告應用程序的健康指標,這些值由HealthIndicator的實現類提供 GET /info 獲取應用程序的定制信息,這些信息由info打頭的屬性提供 GET /mappings 描述全部的URI路徑,以及它們和控制器(包含Actuator端點)的映射關系 GET /metrics 報告各種應用程序度量信息,比如內存用量和HTTP請求計數 GET /metrics/{name} 報告指定名稱的應用程序度量值 POST /shutdown 關閉應用程序,要求endpoints.shutdown.enabled設置為true GET /trace 提供基本的HTTP請求跟蹤信息(時間戳、HTTP頭等)以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章: