Hystrix Dashboard出现Unable to connect to Command Metric Stream.

初次使用Hystrix Dashboard(豪猪哥图像化界面)出现以下提示
莫慌在这里插入图片描述
莫慌,打开控制台看下什么原因

Origin parameter: http://localhost:8989/hystrix.stream is not in the allowed list of proxy host names.  If it should be allowed add it to hystrix.dashboard.proxyStreamAllowList

当出现上述原因,尝试在两个地方做修改:
1.修改对应的Hystrix Dashboard工程中的配置文件,加入以下配置

hystrix.dashboard.proxy-stream-allow-list=localhost

2.在被监控工程的主启动类中加入以下配置

 @Bean
  public ServletRegistrationBean getServlet()
  {
    HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
    registrationBean.setLoadOnStartup(1);
    registrationBean.addUrlMappings("/hystrix.stream");//这行尤为重要,切记不能写错,假如我监控的地址是http://localhost:8989/hystrix.stream,那么双引号里需写/hystrix.stream
    registrationBean.setName("HystrixMetricsStreamServlet");
    return registrationBean;
  }

上述工作做完再打开豪猪哥图形化界面
在这里插入图片描述
紧接着浏览器输入测试地址,监测成功
在这里插入图片描述

ps:SpringBoot为2.3版本,SpringCloud版本为Hoxton.SR8,监测工程和被监控工程pom文件中都必须添加以下依赖

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

以上为个人学习中遇到的问题及解决

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值