一、Hystrix Turbine简介

看单个的Hystrix Dashboard的数据并没有什么多大的价值,要想看这个系统的Hystrix Dashboard数据就需要用到Hystrix Turbine。Hystrix Turbine将每个服务Hystrix Dashboard数据进行了整合。Hystrix Turbine的使用非常简单,只需要引入相应的依赖和加上注解和配置就可以了。

二、准备工作

本文使用的工程为上一篇文章的工程,在此基础上进行改造。因为我们需要多个服务的Dashboard,所以需要再建一个服务,取名为service-lucy,它的基本配置同service-hi,具体见源码,在这里就不详细说明。

三、创建service-turbine

引入相应的依赖:

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

在其入口类ServiceTurbineApplication加上注解@EnableTurbine,开启turbine,@EnableTurbine注解包含了@EnableDiscoveryClient注解,即开启了注册服务。

@SpringBootApplication
@EnableTurbine
public class ServiceTurbineApplication { public static void main(String[] args) { new SpringApplicationBuilder(ServiceTurbineApplication.class).web(true).run(args);
}
}

  配置文件application.yml:

spring:
application.name: service-turbine
server:
port: 8769
security.basic.enabled: false
turbine:
aggregator:
clusterConfig: default # 指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问
appConfig: service-hi,service-lucy ### 配置Eureka中的serviceId列表,表明监控哪些服务
clusterNameExpression: new String("default")
# 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称
# 2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default
# 3. 当clusterNameExpression: metadata['cluster']时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/

  

配置文件注解写的很清楚。

四、Turbine演示

依次开启eureka-server、service-hi、service-lucy、service-turbine工程。

打开浏览器输入:http://localhost:8769/turbine.stream,界面如下:

依次请求:

http://localhost:8762/hi?name=forezp

http://localhost:8763/hi?name=forezp

打开:http://localhost:8763/hystrix,输入监控流http://localhost:8769/turbine.stream

点击monitor stream 进入页面:

可以看到这个页面聚合了2个service的hystrix dashbord数据。

源码来源

最新文章

  1. Unity3D 响应摇杆
  2. dubbo 学习总结
  3. 如何重置CentOS 7的Root密码?设置CentOS 7的Root密码的方法与步骤
  4. MVC+AjaxFileUpload文件上传
  5. JAVA中封装JSONUtils工具类及使用
  6. matlab2013a for linux/Ubuntu 安装步骤及创建快捷方式(ubuntu14.04下安装)
  7. Unity中的CG编写Shader系列(Blend)
  8. 【转】linux IO子系统和文件系统读写流程
  9. 从零开始学习前端开发 — 3、CSS盒模型
  10. Spring整合quartz框架实现任务定时调度
  11. java10 - 泛型与枚举
  12. Readme.txt
  13. 和类相关的BIF
  14. PHP并发之Swoole
  15. 论文阅读: End-to-end Learning of Action Detection from Frame Glimpses in Videos
  16. webpack打包vue文件报错,但是cnpm run dev正常,最后我只想说:是我太笨,还是webpack4.4版本太坑
  17. generator自动生成代码
  18. asp.net 验证码
  19. 2002. [HNOI2010]弹飞绵羊【LCT】
  20. vue 大概流程(未完)

热门文章

  1. 把对像生成json并存储到文件
  2. [转帖]是时候深入了解Linux的系统结构
  3. 概率与期望dp相关
  4. 【NOI2007】项链工厂 ——老题新做.jpg
  5. 批处理遍历文件夹执行git pull
  6. 如何查看Win10开机运行了多长时间 - Windows10.Pro
  7. 逆向与反汇编实战(一)--PEiD分析复现
  8. 14-jquery元素节点操作
  9. Nginx 编译安装工程优化
  10. PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)