解决Hystrix Dashboard出现的诸多问题【如访问hystrix.stream出现Whitelabel error page, 访问hystrix出现 Unable to connect 】

解决Hystrix Dashboard出现的诸多问题

问题1:访问http://localhost:8764/hystrix.stream

出现Whitelabel error page错误

问题2:在浏览器访问的正确网址是:http://localhost:8764/hystrix:

但是初入监控网址之后出现错误:Unable to connect to Command Metric Stream

问题3:进入http://localhost:8764/hystrix看到的是一直loading状态

以上问题按照下面正确步骤操作都可以解决:

 

  1. 在启动类要增加getServlet()的接口,同时要注意addUrlMappings的参数

 

@SpringBootApplication

@EnableEurekaClient

@EnableHystrix        

@EnableHystrixDashboard

public class EmDemoEurekaClientRibbonIiApplication {

 

    public static void main(String[] args) {

        SpringApplication.run(EmDemoEurekaClientRibbonIiApplication.class, args);

    }

   

//  //Howard 2019-02-21 add for HystrixDashboard

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

    }

 

}

 

2,附上pom.xml的依赖

<dependencies>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>

        </dependency>

       

        <!-- Howard 2019-02-21 add for hystrix-dashboard -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-actuator</artifactId>

        </dependency>

        <!-- Howard 2019-02-21 add for hystrix-dashboard -->

        <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-test</artifactId>

            <scope>test</scope>

        </dependency>

    </dependencies>

 

3,step1,访问http://localhost:8764/hystrix.stream看到是一些ping,没有数据,正常。

step2访问htpp://localhost:8764/hystrix,然后在界面填写:http://localhost:8764/hystrix.stream、2000、howard

看到的是loading,这是因为在等待。

step3再访问htpp://localhost:8764/hi?name=howard

step4再刷新上面step1/step2的操作出现的页面,就能正常看到数据了。

 

参考:

https://blog.csdn.net/dangshushu/article/details/80416042

https://www.cnblogs.com/hejianjun/p/8670693.html

https://www.cnblogs.com/x1mercy/p/9291348.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值