解决 Hystrix Dashboard 出现 Unable to connect to Command Metric Stream 的问题
dashboard 版本
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.2.9.RELEASE</version>
</dependency>
需要增加一个 bean
@Bean
public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean =
new ServletRegistrationBean<>(new HystrixMetricsStreamServlet());
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/actuator/hystrix.stream");// 访问路径
registrationBean.setName("hystrix.stream");
return registrationBean;
}
并且设置 proxy-stream-allow-list
hystrix:
dashboard:
proxy-stream-allow-list: '*'