搜索
您的当前位置:首页正文

hystrixDashboard报错:Unable to connect to Command Metric Stream

来源:易榕旅网

当我们配置hystrix的服务监控的时候,出现报错:Unable to connect to Command Metric Stream,并且访问页面是404.这是因为新版本的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;
}
 

然后在访问http://xxxx:xxxx/hystrix即可。

注意:这段代码不是加在hystrixDashboard微服务中,而是加在被监控的微服务启动类上。

注意:这段代码不是加在hystrixDashboard微服务中,而是加在被监控的微服务启动类上。

注意:这段代码不是加在hystrixDashboard微服务中,而是加在被监控的微服务启动类上。

因篇幅问题不能全部显示,请点此查看更多更全内容

Top