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

在生产环境中,需要实时或定期监控服务的可用性。Spring Boot的actuator(健康监控)功能提供了很多监控所需的接口,可以对应用系统进行配置查看、相关功能统计等。

集成:

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

如果使用HTTP调用的方式,还需要这个依赖:

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

配置:

application.yml中指定监控的HTTP端口(如果不指定,则使用和Server相同的端口);指定去掉某项的检查(比如不监控health.mail):

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

使用:

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示例:

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

 

参考:

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

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

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值