避坑指南(二):hystrix.stream端点404问题

转载请注明作者及出处:

作者:银河架构师

原文链接:https://blog.csdn.net/liuminglei1987/article/details/103891303

问题描述

在项目中集成断路器监控的时候,访问/actuator/htstrix.stream经常会遇到404问题,如下图所示:

此问题根本原因就在于此端点压根就没创建,所以,才会报404错误。

 

分析解决

如何排查呢?具体有以下几点:

actuator依赖

查确认否引入了spring-boot-starter-actuator依赖。另外,spring-boot-starter-actuator、spring-cloud-starter-netflix-hystrix、spring-cloud-starter-netflix-hystrix-dashboard三个依赖,缺一不可。

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

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>

 

@EnableHystrixDashboard注解

确认启动类是否引入了@EnableHystrixDashboard注解。

 

@EnableCircuitBreaker注解

确认启动类是否添加了@EnableCircuitBreaker注解。这个是忽略比较多的一项重要原因。

 

@EnableHystrix

如果项目基于ribbon,确认启动类是否添加了@EnableHystrix注解。

 

feign开启hystrix

feign.hystrix.enabled是否为true。需要注意的是,此参数不会影响端点创建,只会影响feign的熔断降级功能是否开启。

 

配置

确认management.endpoints.web.exposure.include包含的有hystrix.stream,或者直接为'*'。此项为最常见的原因,前面都检查过了,都没问题,那就100%是这个原因了。

management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream
management:
  endpoints:
    web:
      exposure:
        include: '*'

 

最后,如果全部点均排除完毕,配置也正确,那么,启动项目之后,查看控制台,出现如下提示即算成功。

 

明确提示,注册hystrix.stream-actuator-endpoint端点/actuator/hystrix.stream成功

 

刷新/actuator/hystrix.stream端点,已正常出现ping命名获取数据。

 

 

微信搜索【银河架构师】,发现更多精彩。

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值