actuator 配置說明

actuator 配置說明

作用

主要是完成微服務的監控,完成監控治理。可以查看微服務間的數據處理和調用,當它們之間出現了異常,就可以快速定位到出現問題的地方。

依賴

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

配置

SpringBoot2.x相對於1.5.x版本而言,Actuator也發生很多變化,配置也發生了相應的變化。

基本配置

# 端口號
management.server.port=9001
# API路徑
management.server.servlet.context-path=/
# health是否顯示細節,可選never,always,when-authenticated
management.endpoint.health.show-details=always
# 公開所有端點,默認只有端點/health和/info端點是暴露的,可以通過include和exclude進行包括和排除
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env

1.5.x與2.x版本屬性比較

舊的屬性 新的屬性
endpoints..* management.endpoint..*
endpoints.cors.* management.endpoints.web.cors.*
endpoints.jmx.* management.endpoints.jmx.*
management.address management.server.address
management.context-path management.server.servlet.context-path
management.ssl.* management.server.ssl.*
management.port management.server.port

說明:
SpringBoot2.x已經去掉了management.security的配置

endpoints接口信息

  • 所有 endpoints 默認情況下都已移至"/actuator"。即多了根路徑actuator
  • 默認只有端點/health和/info端點是暴露的。

endpoints屬性

HTTP 方法 路徑 描述
GET /actuator/conditions 提供了一份自動配置報告,記錄哪些自動配置條件通過了,哪些沒通過(之前爲autoconfig)
GET /actuator/configprops 描述配置屬性(包含默認值)如何注入Bean
GET /actuator/beans 描述應用程序上下文裏全部的Bean,以及它們的關係
GET /actuator/dump 獲取線程活動的快照
GET /actuator/env 獲取全部環境屬性
GET /actuator/env/{name} 根據名稱獲取特定的環境屬性值
GET /actuator/health 報告應用程序的健康指標,這些值由HealthIndicator的實現類提供
GET /actuator/info 獲取應用程序的定製信息,這些信息由info打頭的屬性提供
GET /actuator/mappings 描述全部的URI路徑,以及它們和控制器(包含Actuator端點)的映射關係
GET /actuator/metrics 報告各種應用程序度量信息,比如內存用量和HTTP請求計數
GET /actuator/metrics/{name} 報告指定名稱的應用程序度量值
POST /actuator/shutdown 關閉應用程序,要求endpoints.shutdown.enabled設置爲true
GET /actuator/httptrace 提供基本的HTTP請求跟蹤信息(時間戳、HTTP頭等)(之前爲trace)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章