hystrix dashboard Unable to connect to Command Metric Stream解决办法

大家好我是酷酷的韩~ 下面是遇到的在springcloud熔断器监测中出现以上错误的解决办法。
在这里插入图片描述
1.首先查看依赖是否配置全

 <!--熔断器-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <!--熔断可视化组件-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2.检查启动类是否有如下注解

@EnableCircuitBreaker //断路器
@EnableHystrixDashboard //断路器可视化

3.如果都没问题那么检查下springboot 版本如果是2.0则需要添加 ServletRegistrationBean 因为springboot的默认路径不是 “/hystrix.stream”,只要在自己的项目里配置上下面的servlet就可以了。

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

4.启动熔断器可视化界面
输入地址http:ip:port/hystrix ,如下界面:
在这里插入图片描述
男儿不展风云志,空负天生八尺躯。------酷酷的韩

GitHub 加速计划 / da / dashboard
8
2
下载
General-purpose web UI for Kubernetes clusters
最近提交(Master分支:18 天前 )
2f3f7b01 * feat(pod): add GPU resource allocation support and refactor request/limit functions * test(pod): add GPU allocation resource validation in unit tests 2 天前
1d1d9f43 * Add argument to Dashboard API to allow for a custom CA bundle * add tls bundle to auth * fix CA file usage with custom bundle path * override client config to after config exiss * fix whitespace * Review arguments documentation 8 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐