Hystrix Dashboard集成Turbine
turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过turbine来监控集群下hystrix的metrics情况,通过eureka来发现hystrix服务。
服务说明
上一篇讲了Hystrix Dashboard,实现了断路器的监控,但在微服务架构下,每个服务必然会有多个实例,一个一个实例监控会非常麻烦,这里我们介绍Turbine来实现服务断路器集群监控。
应用说明
使用框架
- SpringBoot 2.0.3
- SpringCloud Finchley.RELEASE
环境搭建
pom依赖
<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>
<!-- hystrix仪表盘 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
启动类修改
在Spring启动类上添加注释**@EnableTurbine**
配置文件
server:
port: 8763
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
application:
name: cloud-hystrix-dashboard
turbine:
aggregator:
cluster-config: default
app-config: app-console-web
instanceUrlSuffix: /hystrix.stream
cluster-name-expression: new String("default")
访问
- 启动应用,输入地址:http://localhost:8763/hystrix
- 在页面中输入地址:http://localhost:8763/turbine.stream
- 点击monitor stream
- 调用一次Hystrix接口就可以在页面看到效果了
示例代码
https://gitee.com/xiaoxming/cloud_project/tree/master/cloud-hystrix-dashboard