解决办法: 这都是 业务微服务端更改。不是 htystrix
显示的 声明一个 servlet组
/**
*此配置是为了服务监控而配置,与服务容错本身无关,springcloud升级后的坑
*ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
*只要在自己的项目里配置上下面的servlet就可以了
* cloud更改前的路径应该是 /actuator/hystrix
*/
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
确认是否引入 actuator 的依赖
一切准备完成后。 访问 htystrix 检测的地址 : localhost:端口/htystrix.stream . 进行业务访问 。发现有 ping出现。说明此时客户端没有问题了
将此地址配入 htystrix
查看是否能正确访问:
如果还是出现 Unable to connect to Command Metric Stream. 查看一下log日志。 发现是 could'n allow list. 那么在 htystrict端的 application.yml 文件中。配置host允许
hystrix:
dashboard:
proxy-stream-allow-list: localhost
TRANSLATE with x
English
TRANSLATE with
COPY THE URL BELOW
Back
EMBED THE SNIPPET BELOW IN YOUR SITE
Enable collaborative features and customize widget: Bing Webmaster Portal
Back
/**
*此配置是为了服务监控而配置,与服务容错本身无关,springcloud升级后的坑
*ServletRegistrationBean因为springboot的默认路径不是"/hystrix.stream",
*只要在自己的项目里配置上下面的servlet就可以了
* cloud更改前的路径应该是 /actuator/hystrix.stream
*/
@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章