zoukankan      html  css  js  c++  java
  • SpringCloud Hystrix dashboard2.2.7使用和配置,SpringCloud Hystrix dashboard服务监控

    SpringCloud Hystrix dashboard2.2.7使用和配置,SpringCloud Hystrix dashboard服务监控

    Unable to connect to Command Metric Stream.解决方案

     

    ================================

    ©Copyright 蕃薯耀 2021-03-15

    https://www.cnblogs.com/fanshuyao/

    一、SpringCloud Hystrix使用和配置

    SpringCloud Hystrix使用和配置,见:

    https://www.cnblogs.com/fanshuyao/p/14537475.html

    项目:

    服务消费者:springCloud-hystrix-web-8655
    服务监控:springCloud-hystrix-dashboard-8656

    二、SpringCloud Hystrix dashboard使用和配置(服务监控:springCloud-hystrix-dashboard-8656)

    1、pom.xml引入依赖
    引入:spring-cloud-starter-netflix-hystrix-dashboard、spring-boot-starter-actuator

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        <version>2.2.7.RELEASE</version>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    2、application.properties配置文件修改

    #监控访问地址:http://127.0.0.1:8656/hystrix
    #要监控的地址:http://127.0.0.1:8655/actuator/hystrix.stream
    server.port=8656
    
    #必须要配置hystrix.dashboard.proxy-stream-allow-list,不然进入监听页面,会报错:Unable to connect to Command Metric Stream.
    
    #控制台输出:ashboardConfiguration$ProxyStreamServlet : Origin parameter: http://127.0.0.1:8655/actuator/hystrix.stream is not in the allowed list of proxy host names.  If it should be allowed add it to hystrix.dashboard.proxyStreamAllowList.
    
    #配置的访问列表的地址,必须一一对应:
    #如使用:http://127.0.0.1:8655/actuator/hystrix.stream访问,就配置hystrix.dashboard.proxy-stream-allow-list=127.0.0.1
    #如使用:http://localhost:8655/actuator/hystrix.stream访问,就配置hystrix.dashboard.proxy-stream-allow-list=localhost
    #不然会出现:Unable to connect to Command Metric Stream.
    hystrix.dashboard.proxy-stream-allow-list=127.0.0.1

    3、启动类
    @EnableHystrixDashboard:启动监控

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
    
    @SpringBootApplication
    @EnableHystrixDashboard
    public class SpringCloudHystrixDashboard8656Application {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringCloudHystrixDashboard8656Application.class, args);
        }
    
    }

    三、服务消费者:springCloud-hystrix-web-8655,修改监控配置

    1、pom.xml引入依赖,actuator不能少

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        <version>2.2.7.RELEASE</version>
    </dependency>

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

    2、application.properties配置文件修改

    #熔断监控暴露的接口,或者使用
    #使用*表示全部
    #management.endpoints.web.exposure.include=*
    management.endpoints.web.exposure.include=hystrix.stream,info,health

    3、启动类
    加上@EnableHystrix,或者@EnableCircuitBreaker,而@EnableHystrix继承于@EnableCircuitBreaker

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
    import org.springframework.cloud.netflix.hystrix.EnableHystrix;
    import org.springframework.cloud.openfeign.EnableFeignClients;
    
    @SpringBootApplication
    @EnableFeignClients
    @EnableEurekaClient
    @EnableHystrix
    public class SpringCloudHystrixWeb8655Application {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringCloudHystrixWeb8655Application.class, args);
        }
    
    }


    四、启动测试
    启动服务消费者和服务监控

    1、在浏览器输入地址:

    http://127.0.0.1:8656/hystrix

    2、在输入框输入监控的地址(服务消费者的监控地址):

     这里的地址是有/actuator的,有些版本是没有这个的。

    http://127.0.0.1:8655/actuator/hystrix.stream

    听说这样能把/actuator去掉(未验证):

    #修改base-path,默认是/actuator
    #private String basePath = "/actuator";
    management.endpoints.web.base-path=/

    3、Delay和title自己定义就好

    4、点击Monitor Stream按钮进入监控页面,然后调用服务消费者的接口产生服务调用数据

    5、当一个服务请求不断发生错误,如10秒中产生20次请求,且请求失败率达到50%以上,此服务就会发生熔断(仅是单个服务,其它服务不影响)


    五、注意事项


    1、Unable to connect to Command Metric Stream.

    问题原因是:

    ashboardConfiguration$ProxyStreamServlet : Origin parameter: http://127.0.0.1:8655/actuator/hystrix.stream is not in the allowed list of proxy host names.  If it should be allowed add it to hystrix.dashboard.proxyStreamAllowList.

    翻译:ashboardConfiguration $ ProxyStreamServlet:原始参数:http://127.0.0.1:8655/actuator/hystrix.stream不在代理主机名的允许列表中。 如果应允许将其添加到hystrix.dashboard.proxyStreamAllowList。

    就是要配置:hystrix.dashboard.proxy-stream-allow-list

    解决方法是:

    在服务监控:springCloud-hystrix-dashboard-8656项目的application.properties增加:hystrix.dashboard.proxy-stream-allow-list

    #配置的访问列表的地址,必须一一对应:
    #如使用:http://127.0.0.1:8655/actuator/hystrix.stream访问,就配置hystrix.dashboard.proxy-stream-allow-list=127.0.0.1
    #如使用:http://localhost:8655/actuator/hystrix.stream访问,就配置hystrix.dashboard.proxy-stream-allow-list=localhost
    #不然会出现:Unable to connect to Command Metric Stream.
    hystrix.dashboard.proxy
    -stream-allow-list=127.0.0.1

    (时间宝贵,分享不易,捐赠回馈,^_^)

    ================================

    ©Copyright 蕃薯耀 2021-03-15

    https://www.cnblogs.com/fanshuyao/

    今天越懒,明天要做的事越多。
  • 相关阅读:
    [转载]vue中全局和局部引入批量组件方法
    [转]详解在vue-test-utils中mock全局对象
    [转]imageMagick 在nodejs中报错Error: spawn identify ENOENT的解决方案
    使用 dva 如何配置异步加载路由组件
    dva.js 上手
    [转]axios的兼容性处理
    【转】链接伪类(:hover)CSS背景图片有闪动BUG
    【转】 svn: Server sent unexpected return value (403 Forbidden) in response to CHECKOUT request for-解决方法
    vue 路由相同路径跳转报错
    新手小白第一次与后端联调
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/14539320.html
Copyright © 2011-2022 走看看