Spring Boot Actuator

springBootActuator

官方文档地址https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

  • 提供很多监控端点(endpoint)
1.使用,消费者,提供者都引入依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2.health

访问http://localhost:8088/actuator/health (springboot2版本路径中多了个actuator)

返回值:

{"status":"UP"}

UP:运行正常

Down

OUT_OF_SERVICE

UNKNOWN

只显示的概要情况,展示详情需要添加配置

 

  • 1.5之前需要配置中添加
    management.security.enabled=false来暴露所有端点
  • 2.0之后
    • management.endpoints.web.exposure.include=* 暴露所有端点,默认只暴露health和info端点(出于安全考虑)
    • 
      # 启用端点 env
      management.endpoint.env.enabled=true
       
      # 暴露端点 env 配置多个,隔开
      management.endpoints.web.exposure.include=env

       暴露单个端点或者多个端点

或者添加security启动依赖,允许有actuator角色的用户访问所有端点

  •  management.endpoint.health.show-details=always#显示健康具体信息 默认不会显示详细信息

3.info 

默认情况info访问后返回{}

在配置文件中配置

info:
   app:
     name: @project.artifactId@
     encoding: @project.build.sourceEncoding@
     java:
       source: @java.version@
       target: @java.version@

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值