Hystrix:Unable to connect to Command Metric Stream

 版本

java.version 13
spring-boot 2.2.3.RELEASE
spring-cloud Hoxton.SR3

问题 

Hystrix:Unable to connect to Command Metric Stream_第1张图片 

Hystrix:Unable to connect to Command Metric Stream_第2张图片

原因 

 springboot默认路径为"/"需要修改为"/hystrix.stream"

HystrixMetricsStreamServlet源码中给出通过xml配置

再springboot中我们可以采用@Bean方式配置

Hystrix:Unable to connect to Command Metric Stream_第3张图片

解决方法

增加

    @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;
    }

或者yml文件中加入

management:
  enabled: false
  endpoints:
    web:
      exposure:
        include: hystrix.stream
      base-path: /

重启一下ok

Hystrix:Unable to connect to Command Metric Stream_第4张图片

你可能感兴趣的:(Spring,Cloud)