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 ...
随机推荐
- javaScript对象——function对象
1.基本对象和Function(函数)方法对象 2.概念 3.创建function对象的三种方式: 第一种不建议使用 2.3两种方式就是方法名位置不同,建议使用: 4.方法调用只要名字对,实参不一定完 ...
- 《手把手教你》系列技巧篇(二十六)-java+ selenium自动化测试-浏览器操作(详细教程)
1.简介 在Web自动化的操作中,我们通常需要使用一些方法来操作浏览器,今天就来学习一下.这一篇宏哥主要是介绍一下,在自动化测试的时候,我们常见的一些浏览器操作有哪些,宏哥将会一一介绍和讲解. 2.浏 ...
- 详解Java中==和equals()的区别
众所周知,在 Java 编程中,程序员通常会使用==或equals()来简单的比较地址,内容是否相等.而这两者之间的使用区别,对于初学 Java 的同学来说可能会比较迷糊.我将根据下面的几段示例程序, ...
- 通过Wireshark抓包分析谈谈DNS域名解析的那些事儿
文/朱季谦 本文主要想通过动手实际分析一下是如何通过DNS服务器来解析域名获取对应IP地址的,毕竟,纸上得来终觉浅,绝知此事要躬行. 域名与IP地址 当在浏览器上敲下"www.baidu.c ...
- 【PHP数据结构】散列表查找
上篇文章的查找是不是有意犹未尽的感觉呢?因为我们是真真正正地接触到了时间复杂度的优化.从线性查找的 O(n) 直接优化到了折半查找的 O(logN) ,绝对是一个质的飞跃.但是,我们的折半查找最核心的 ...
- 彻底搞明白PHP中的include和require
在PHP中,有两种包含外部文件的方式,分别是include和require.他们之间有什么不同呢? 如果文件不存在或发生了错误,require产生E_COMPILE_ERROR级别的错误,程序停止运行 ...
- 创建一个新的解耦的Orchard Core CMS网站
引言本文将介绍创建一个功能齐全.解耦的CMS网站的过程,该网站允许您编辑博客帖子并呈现它们.解耦是一种开发模型,其中站点的前端和后端(管理)托管在同一个Web应用程序中,但只有后端由CMS驱动.然后, ...
- k8s garbage collector分析(2)-处理逻辑分析
garbage collector介绍 Kubernetes garbage collector即垃圾收集器,存在于kube-controller-manger中,它负责回收kubernetes中的资 ...
- 鸿蒙内核源码分析(任务切换篇) | 看汇编如何切换任务 | 百篇博客分析OpenHarmony源码 | v41.03
百篇博客系列篇.本篇为: v41.xx 鸿蒙内核源码分析(任务切换篇) | 看汇编如何切换任务 | 51.c.h .o 任务管理相关篇为: v03.xx 鸿蒙内核源码分析(时钟任务篇) | 触发调度谁 ...
- AT2368-[AGC013B]Hamiltonish Path【构造】
正题 题目链接:https://www.luogu.com.cn/problem/AT2368 题目大意 给出 \(n\) 个点 \(m\) 条边的一张无向图,然后求一条路径满足 路径长度不小于二. ...