SpringCloud Hystrix dashboard2.2.7使用和配置,SpringCloud Hystrix dashboard服务监控
Unable to connect to Command Metric Stream.解决方案
================================
©Copyright 蕃薯耀 2021-03-15
http://fanshuyao.iteye.com/
一、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
http://fanshuyao.iteye.com/
相关推荐
spring cloud hystrix通过服务隔离、熔断、降级等手段控制依赖服务的延迟与失败。
spring cloud hystrix &&dashboard源码解读
springcloud hystrix 断路由 http://knight-black-bob.iteye.com/blog/2356431
springcloud hystrix jar包,java -jar xx.jar,小熊界面
spring-cloud-hystrix-dashboard(包含注册中心、member、hystrix-dashboard配置等).zip 包含配置好的eureka注册中心,member服务生产者、hystrix-dashboard的hystrix配置和仪表盘配置
Spring Cloud Netfix Hystrix断路器例子工程。使用Spring Cloud Netflix Hystrix以及Spring RestTemplate或Spring Cloud Netflix Feign实现断路器模式。
SpringCloud Hystrix服务熔断
springcloud hystrix-dashboard
Spring Cloud(Hystrix)使用,通过代码学习Spring Cloud(Hystrix)使用.。
Hystrix Dashboard的使用博文中,优化后的服务消费者和服务提供者,Hystrix Dashboard工程、Turbine工程,以及Eureka Server、父级工程的源代码
springcloud hystrix+feign
spring cloud hystrix 服务容错保护例子,加上Eureka server就可以直接运行了。如果出现错误,会调用指定的方法
主要介绍了SpringCloud Hystrix-Dashboard仪表盘的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Spring Cloud(五)断路器监控(Hystrix Dashboard) spring-cloud-zuul Spring Cloud(六)服务网关 zuul 快速入门 spring-cloud-zuul-filter Spring Cloud(七)服务网关 Zuul Filter 使用 spring-...
详细讲解了如何在Spring Cloud中使用Hystrix,如何将Hystrix整合到Feign中
SpringCloud10-2 Hystrix整合Dashboard教程
主要介绍了Spring Cloud Hystrix 线程池队列配置(踩坑),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
spring cloud
hystrix-dashboard-turbine:熔断监控Hystrix Dashboard和Turbine的示例 spring-cloud-config-git:配置中心git版本示例 spring-cloud-config-svn-refresh:配置中心svn版本示例,客户端refresh版本示例 spring-...
spring-cloud-netflix-hystrix-dashboard-2.2.3.RELEASE.jar