spring-boot-starter-actuator(健康監控)配置和使用

在生產環境中,須要實時或按期監控服務的可用性。Spring Boot的actuator(健康監控)功能提供了不少監控所需的接口,能夠對應用系統進行配置查看、相關功能統計等。git

集成:github

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

若是使用HTTP調用的方式,還須要這個依賴:web

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

配置:spring

application.yml中指定監控的HTTP端口(若是不指定,則使用和Server相同的端口);指定去掉某項的檢查(好比不監控health.mail):segmentfault

server:  
  port: 8082  
management:  
  port: 54001  
  health:  
    mail:  
      enabled: false  

使用:app

HTTP方法 路徑 描述 鑑權
GET /autoconfig 查看自動配置的使用狀況 true
GET /configprops 查看配置屬性,包括默認配置 true
GET /beans 查看bean及其關係列表 true
GET /dump 打印線程棧 true
GET /env 查看全部環境變量 true
GET /env/{name} 查看具體變量值 true
GET /health 查看應用健康指標 false
GET /info 查看應用信息(須要本身在application.properties裏頭添加信息,好比info.contact.email=easonjim@163.com) false
GET /mappings 查看全部url映射 true
GET /metrics 查看應用基本指標 true
GET /metrics/{name} 查看具體指標 true
POST /shutdown 關閉應用(要真正生效,得配置文件開啓endpoints.shutdown.enabled: true) true
GET /trace 查看基本追蹤信息 true

 

Maven示例:spring-boot

https://github.com/easonjim/spring-cloud-demo/tree/master/ZooKeeperurl

 

參考:spa

https://segmentfault.com/a/1190000004318360?_ea=568366.net

http://blog.csdn.net/clementad/article/details/52045495

http://www.jianshu.com/p/734519d3c383

相關文章
相關標籤/搜索