zoukankan      html  css  js  c++  java
  • Hystrix dashboard - Unable to connect to Command Metric Stream.

    在使用boot 2.0.*以上版本 + cloud Finchley.RELEASE

    查看仪表盘的时候会报错

    Unable to connect to Command Metric Stream

               <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Finchley.RELEASE</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-dependencies</artifactId>
                    <version>2.0.2.RELEASE</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>

    解决方案:

      
    在项目中添加配置注意红色部分

    package com.amber.config;
    
    import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
    import org.springframework.boot.web.servlet.ServletRegistrationBean;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    @Configuration
    public class HystrixConfig {
    
        @Bean
        public ServletRegistrationBean getServlet(){
            HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
            ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
            registrationBean.setLoadOnStartup(1);
            registrationBean.addUrlMappings("/actuator/hystrix.stream");
            registrationBean.setName("HystrixMetricsStreamServlet");
            return registrationBean;
        }
    }                                                                                                     

    然后就成功了

  • 相关阅读:
    JAVA程序操作hbase的Maven配置pom.xml文件
    windows下部署icescrum
    第一次博客作业——简单介绍一下自己
    2019寒假训练营第三次作业
    网络空间安全概论第5单元笔记
    2019寒假训练营第二次作业
    网络空间安全概论1、4单元笔记
    2019寒假训练营第一次作业
    软工实践个人总结
    第4次作业-结对编程之实验室程序实现
  • 原文地址:https://www.cnblogs.com/amberbar/p/10123892.html
Copyright © 2011-2022 走看看