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

    然后就成功了

  • 相关阅读:
    云计算安全之传统安全业务连续性和灾难恢复
    如何降低云应用程序的风险并管理其保障措施
    映射函数
    numpy用法
    dataframe基础
    list用法
    可视化基础
    pycharm使用技巧
    时间用法
    merge()函数
  • 原文地址:https://www.cnblogs.com/amberbar/p/10123892.html
Copyright © 2011-2022 走看看