解决 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: '*'
posted @ 2022-08-03 19:13  博麗靈夢  阅读(64)  评论(0编辑  收藏  举报