hystrix的dashboard和turbine监控
当我们的应用程序使用了hystrix后,每个具体的hystrixCommand命令执行后都会产生一堆的监控数据,比如:成功数,失败数,超时数以及与之关联的线程池信息等。既然有了这些监控数据数据,那么我们应该如何进行查看呢?答案当然是通过hystrix dashboard 来进行查看,但hystrix dashboard只能查看单个应用内的服务信息,这个显然是不够的,因此我们需要一个能够将系统内多个服务的监控数据汇总到hystrix dashboard上,这个时候就应该使用turbine.
实现功能
假设我们存在服务消费方 product-consumer 和 order-consumer,且都使用了hystrix
1、查看单个服务的 hystrix dashboard 信息
|- 即 product-consumer 只部署在一台机器上
2、查看单个集群的 hystrix dashboard 信息
|- 即 product-consumer 部署在了多台机器上
3、查看多个集群的 hystrix dashboard 信息
|- 即 product-consumer 和 order-consumer 都部署在了 1台~多台 机器上
4、查看所有集群的 hystrix dashboard 信息
|- 查看这个注册中心中所有的服务消费者的监控数据
前置条件
hystrix dashboard url 的格式
监控图标的指标信息

一、查看单个服务的 hystrix dashboard 的信息
1、代码结构:
2、hystrix dashboard程序的编写 ,注册中心、提供者和消费者略
1、引入依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
主要是引入 spring-cloud-starter-netflix-hystrix-dashboard 这个依赖
2、启动上增加 @EnableHystrixDashboard 注解
@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
public class ProductHystrixDashboard8097Application {
public static void main(String[] args) {
SpringApplication.run(ProductHystrixDashboard8097Application.class, args);
}
}
3、配置文件(application.yml)没有什么需要注意的,注册到eureka上即可。
4、运行结果

二、查看单个集群的 hystrix dashboard 信息
1、代码结构

2、服务提供者和注册中心略
3、服务消费者
1、java代码就是一个简单的调用远程服务(略)
2、配置文件的写法
server:
port: 8100 eureka:
client:
service-url:
defaultZone : http://${security.user.name}:${security.user.password}@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${server.port}
lease-renewal-interval-in-seconds: 3
lease-expiration-duration-in-seconds: 9
metadata-map:
cluster: PRODUCT security:
user:
name: root
password: admin
spring:
application:
name: product-consumer
需要注意: eureka.instance.metadata-map.cluster 的值,在 turbine 工程中这个值被使用到了
4、turbine 工程的写法
1、引入依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</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>
2、增加 @EnableHystrixDashboard @EnableTurbine 注解
@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
@EnableTurbine
public class ProductHystrixDashboard8101Application {
public static void main(String[] args) {
SpringApplication.run(ProductHystrixDashboard8101Application.class, args);
}
}
3、配置文件的写法
server:
port: 8101
eureka:
client:
service-url:
defaultZone : http://${security.user.name}:${security.user.password}@localhost:8761/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${server.port}
security:
user:
name: root
password: admin
spring:
application:
name: product-hystrix-turbine-dashboard-8101
logging:
level:
org.hibernate : info
org.hibernate.type.descriptor.sql.BasicBinder : trace
org.hibernate.type.descriptor.sql.BasicExtraator : trace
info:
app:
name: "product-hystrix-turbine-dashboard-8101"
description: "product-hystrix-turbine-dashboard-8101程序"
version: "0.0.1"
turbine:
app-config: product-consumer
aggregator:
cluster-config: PRODUCT
combine-host-port: true
cluster-name-expression: metadata['cluster']
注意:
1、主要最后一段配置是和turbine相关,即 turbine 开头的配置
2、turbine.app-config: 后方写的是服务名,即存在hystrim的服务的spring.application.name的值
3、turbine.aggregator.cluster-config: 需要聚合的集群的名字列表,和服务消费者里面的eureka.instance.metadata-map.cluster的值一致
4、turbine.cluster-name-expression: 获取集群名称的表达式,此处指的是获取元数据cluster的值。
5、 turbine.combine-host-port: 为true 表示可以让同一主机上的服务通过主机名和端口号的组合来进行区分
5、整体代码架构

需要理清上面各个线的对应关系。
6、运行结果

三、查看多个集群的 hystrix dashboard 信息
服务注册中心、服务提供者、服务消费者和单个集群的配置是一样的。
turbine 工程中的yml配置
turbine:
app-config: product-consumer,order-consumer
aggregator:
cluster-config: PRODUCT
combine-host-port: true
cluster-name-expression: metadata['cluster']
app-config: 如果有多个,中间以逗号分隔
cluster-config:如果有多个,中间以都好分隔
hystrix dashboard页面上的访问路径: http://turbine:port/turbine.stream?cluster=[cluster-config中的值]
四、查看所有集群的 hystrxi dashboard 监控信息
服务注册中心、服务提供者、服务消费者和单个集群的配置是一样的。
服务消费者工程不需要 eureka.instance.metadata-map.cluster的配置了。
turbine 工程中的yml配置
turbine:
app-config: product-consumer,order-consumer
combine-host-port: true
cluster-name-expression: "'default'"
app-config:需要聚合的服务名,有多个中间以 逗号 分开
cluster-name-expression 的值修改成 default
hystrix dashboard页面上的访问路径: http://turbine:port/turbine.stream
完整代码
上方四个工程的完整代码如下: https://gitee.com/huan1993/spring-cloud-parent/tree/master/hystrix-dashboard-turbine
hystrix的dashboard和turbine监控的更多相关文章
- Spring Cloud 入门教程(八): 断路器指标数据监控Hystrix Dashboard 和 Turbine
1. Hystrix Dashboard (断路器:hystrix 仪表盘) Hystrix一个很重要的功能是,可以通过HystrixCommand收集相关数据指标. Hystrix Dashboa ...
- spring cloud Hystrix监控面板Hystrix Dashboard和Turbine
我们提到断路器是根据一段时间窗内的请求情况来判断并操作断路器的打开和关闭状态的.而这些请求情况的指标信息都是HystrixCommand和HystrixObservableCommand实例在执行过程 ...
- 跟我学SpringCloud | 第五篇:熔断监控Hystrix Dashboard和Turbine
SpringCloud系列教程 | 第五篇:熔断监控Hystrix Dashboard和Turbine Springboot: 2.1.6.RELEASE SpringCloud: Greenwich ...
- 微服务SpringCloud之熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- Hystrix之Dashboard的常见问题
Hystrix Dashboard (断路器:Hystrix 仪表盘)只监控一个实例,而Turbine监控多个实例,要使用Turbine必须使用Hystrix,因为Turbine是为了监控断路器的状态 ...
- springcloud(五):熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- spring cloud(五)熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- Spring Cloud(五):熔断监控Hystrix Dashboard和Turbine
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...
- springcloud-熔断监控Hystrix Dashboard和Turbine
作者:纯洁的微笑出处:http://www.ityouknow.com/ 版权归作者所有,转载请注明出处 Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystri ...
随机推荐
- openswan协商流程之(四):main_inI2_outR2()
主模式第四包:main_inI2_outR2 1. 序言 main_inI2_outR2()函数是ISAKMP协商过程中第四包的核心处理函数的入口,同时在此处理流程中已经获取到足够的隧道信息,可以生成 ...
- LayoutControl控件使用
因默认外边距过大需要将外边距缩小用以下代码实现layoutControlGroup1.Padding = DevExpress.XtraLayout.Utils.Padding.Empty;是否允许只 ...
- MySQL实战45讲(01--05)-笔记
目录 MySQL复习 01 | 基础架构:一条SQL查询语句是如何执行的? 连接器 查询缓存 分析器 优化器 执行器 02 | 日志系统:一条SQL更新语句是如何执行的? 重要的日志模块:redo l ...
- shell编程之免交互
目录: 一.Here Document 免交互 二.Expect 一.Here Document 免交互 使用I/O重定向的方式将命令列表提供给交互式程序或命令, 比如 ftp.cat 或 read ...
- (7)java Spring Cloud+Spring boot+mybatis企业快速开发架构之SpringCloud-Spring Boot Starter的介绍及使用
Spring Boot 的便利性体现在,它简化了很多烦琐的配置,这对于开发人员来说是一个福音,通过引入各种 Spring Boot Starter 包可以快速搭建出一个项目的脚手架推荐分布式架构源 ...
- 【第四篇】- Maven 构建生命周期之Spring Cloud直播商城 b2b2c电子商务技术总结
Maven 构建生命周期 Maven 构建生命周期定义了一个项目构建跟发布的过程. 一个典型的 Maven 构建(build)生命周期是由以下几个阶段的序列组成的: 阶段 处理 描述 验证 ...
- netty系列之:在netty中处理CORS
目录 简介 服务端的CORS配置 CorsConfigBuilder CorsHandler netty对cors的支持 总结 简介 CORS的全称是跨域资源共享,他是一个基于HTTP-header检 ...
- 学习PHP中的iconv扩展相关函数
想必 iconv 这个扩展的相关函数大家多少都接触过,做为 PHP 的默认扩展它已经存在了很久,也是我们在操作字符编码时经常会使用的函数.不过除了 iconv() 这个函数外,你还知道它的其它函数吗? ...
- 『PyTorch』屌丝的PyTorch玩法
1. prefetch_generator 使用 prefetch_generator库 在后台加载下一batch的数据,原本PyTorch默认的DataLoader会创建一些worker线程来预读取 ...
- Viterbi 算法 Python实现 [NLP学习一]
最近思考了一下未来,结合老师的意见,还是决定挑一个方向开始研究了,虽然个人更喜欢鼓捣.深思熟虑后,结合自己的兴趣点,选择了NLP方向,感觉比纯粹的人工智能.大数据之类的方向有趣多了,个人还是不适合纯粹 ...