Spring Cloud 2020.0.4环境下Hystrix Dashboard无法加载指标问题求助
问题根因
你所使用的Spring Cloud 2020.0.x(代号Ilford)版本已官方移除Hystrix默认适配,网关中配置的CircuitBreaker默认采用Resilience4j实现,生成的指标格式无法被Hystrix Dashboard解析。你访问/actuator/hystrix.stream仅能看到ping返回,不存在实际的业务熔断指标数据,因此Dashboard会一直处于加载状态。
可行解决方案
方案1:保留Hystrix Dashboard,切换CircuitBreaker实现为Hystrix
- 调整网关依赖,排除默认的Resilience4j实现,引入Hystrix适配依赖:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> <version>2.2.9.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-circuit-breaker-hystrix</artifactId> <version>2.1.6.RELEASE</version> </dependency> <!-- 移除原有spring-cloud-starter-circuitbreaker-resilience4j相关依赖 -->
- 在配置文件中开启Hystrix CircuitBreaker支持:
spring: cloud: circuitbreaker: hystrix: enabled: true management: endpoints: web: exposure: include: hystrix.stream,health
- 重启服务后先调用几次业务接口,再访问
http://localhost:9191/actuator/hystrix.stream,确认除ping之外有实际的指标数据输出,再将地址填入Hystrix Dashboard即可正常加载。
方案2:适配Spring Cloud新版本生态,替换监控方案
Hystrix已经停止维护,Spring Cloud新版本更推荐用Resilience4j + Prometheus + Grafana的监控方案:
- 引入
micrometer-registry-prometheus依赖暴露Resilience4j指标 - 用Prometheus采集指标后,直接使用Grafana官方提供的Resilience4j仪表盘即可查看熔断、降级、限流相关的所有指标,适配性和扩展性都优于Hystrix Dashboard。
其他排查点
如果已经切换为Hystrix实现仍然加载失败,可以检查以下配置:
- Hystrix Dashboard填写的监控地址是否正确,是否存在网关前缀、上下文路径遗漏
- 服务是否配置了跨域拦截,拦截了Dashboard的指标请求
内容的提问来源于stack exchange,提问作者Tokyo
相关产品推荐
相关产品推荐

