SpringBoot Actuator

SpringBoot Actuator 提供了檢查項目內部信息的一整套API,一般在項目啓動時能夠看到。spring

1.引入依賴包bash

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

2.配置application.ymlapp

management:
  address: 127.0.0.1 #只有當配置了port,bind-address纔會生效.
  port: 8091
  security:
    enabled: true # 默認爲true,生產環境必須設爲true;這個值影響health接口的返回內容,設爲true時,health接口只返回{status:up}
  context-path: /actuator   # 統一actuator的路徑前綴,統一探活接口:/actuator/health
  health:
    defaults:
    # 爲false只檢查應用自己的健康狀態;爲true會對磁盤狀態的進行檢查
    # 但只有management.security.enabled=false時,纔會返回磁盤空間的狀態
      enabled: false # 默認true,檢查磁盤空間
    diskspace:
      enabled: true # 默認true,設爲false,不返回磁盤狀態
      path: D:// # 只檢查應用自己的健康狀態,爲true會對磁盤狀態的進行檢查,若是這個磁盤路徑是不存在的,程序啓動會報錯
# spring-boot 1.4.3 沒有鑑權機制
# 默認 sensitive 是 true,但會被management.security.enabled=false 覆蓋
endpoints:
  enabled: false # 默認true,打開全部接口,設爲false,關閉全部接口(包含health),但單個接口能夠獨立打開
  health:
    enabled: true # 默認true,打開接口
  trace:
    enabled: false # 默認true,設爲false,訪問/actuator/health 返回404
    sensitive: false # 默認true, 設爲false就能夠關閉鑑權
  beans:
    enabled: false # 默認true,打開接口
    sensitive: false # 默認true,設爲false就能夠關閉鑑權
  metrics:
    enabled: false # 默認true,打開接口
    sensitive: true # 默認true,設爲false就能夠關閉鑑權
  info:
    enabled: false # 默認true,打開接口
    sensitive: false # 默認true,設爲false就能夠關閉鑑權
  heapdump:
    enabled: false # 默認true,打開接口
    sensitive: false # 默認true,設爲false就能夠關閉鑑權
相關文章
相關標籤/搜索