当我们的应用程序使用了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
- 大小: 64.5 KB
- 大小: 61.1 KB
- 大小: 48.4 KB
- 大小: 2.2 MB
- 大小: 86.5 KB
- 大小: 229 KB
- 大小: 2.7 MB
分享到:
相关推荐
Hystrix-dashboard+turbine-web+说明文档,用于Hystrix项目的监控、多实例的聚合监控
Hystrix Dashboard的使用博文中,优化后的服务消费者和服务提供者,Hystrix Dashboard工程、Turbine工程,以及Eureka Server、父级工程的源代码
主要介绍了springcloud 熔断监控Hystrix Dashboard和Turbine,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
今天我们就将讲解下Hystrix Dashboard和Turbine.其中Hystrix Dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据,监控...
温疫流行,家中休息期间,再次进行微服务分布架构,HystrixDashboard图表化hystrix/turbine.stream,大部分情况不能获取数据,指示Unable to connect to Command Metric Stream 之前,调试通过的。spring boot版本...
hystrix-dashboard-turbine:熔断监控Hystrix Dashboard和Turbine的示例 spring-cloud-config-git:配置中心git版本示例 spring-cloud-config-svn-refresh:配置中心svn版本示例,客户端refresh版本示例 spring-...
hystrix-dashboard-turbine:熔断监控Hystrix Dashboard和Turbine的示例 spring-cloud-config-git:配置中心git版本示例 spring-cloud-config-svn-refresh:配置中心svn版本示例,客户端refresh版本示例 spring-...
通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的... 我们需要一个工具能让我们汇总系统内多个服务的数据并显示到Hystrix Dashboard上, 这个工具就是Turbine,大神必备神器,导入即用,无需更改和配置!
包含config-server、eureka、fegin+ribbon、SpringCloudBus、Hystrix、8Hystrix Dashboard、turbine、sleuth、sleuth这些组件的使用以及配置。
ribbon负载均衡1,ribbon负载均衡restTemlete消费服务2,feign-ribbon负载均衡消费服务3,hystrix熔断器,hystrix dashboard、turbine监控熔断器状态监控4,zuul网关路由5,sleuth链路追踪
| Spring Cloud使用的各种示例,以最简单、最实用为标准:eureka server单机、双机、集群示例:利用eureka实现服务提供与调用示例:Hystrix熔断的使用示例:熔断监控Hystrix Dashboard和Turbine的示例:...
Hystrix,包括Hystrix Dashboard以及Turbine 配置服务 Spring Cloud Config Server 网关 Zuul 监控中心 Spring-boot-admin 准备 环境准备: 工具 版本或描述 JDK 1.8 IDE IntelliJ IDEA Maven 3.x 主机名配置: 主机...
第二课: 服务消费者(rest+ribbon) 第三课: 服务消费者(Feign) 第四课: 断路器(Hystrix... 第十二课: 断路器监控(Hystrix Dashboard) 第十三课: 断路器聚合监控(Hystrix Turbine) 第十四课: 服务注册(consul)
Dashboard、Turbine聚合监控、Zuul、SpringBootAdmin等Spring Config 、OAuth2未集成进来,但是在我的主页里有单独的实例,后续会慢慢都集成进来。 项目模块: ├── client-common-dependencys ├── client-...
此文件是springboot跟springcloud的整合,搭建一个eureka的服务注册中心,并有服务提供...hystrix dashboard 可视化监控数据。trubine集群监控。博客原文:https://blog.csdn.net/u013083284/article/details/83624617
- [hystrix-dashboard-turbine](https://github.com/ityouknow/spring-cloud-examples/tree/master/hystrix-dashboard-turbine):熔断监控Hystrix Dashboard和Turbine的示例 - [spring-cloud-config-git]...
SpringColud建立微服务注册中心,添加多个服务,使用feign和ribbon以及balancer进行服务之间的访问,使用hystrix或feign进行服务熔断,使用hystrix-dashboard进行服务熔断监控,使用hystrix-turbine整合多个服务熔断...
Spring Cloud 各组件Demo ,包含 Spring Cloud Eureka ,Spring Cloud Zuul , Spring Cloud Ribbon , Hystrix-Dashboard-Turbine 如有错误 ,请于本人联系 ,自会及时修改 , 防止误导他人
consumer ---- Hystrix-dashboard 断路监控项目demo 参考博客地址: https://blog.csdn.net/qq_33333654/article/details/102793842 hystrix-turbine ---- turbine监控统计汇总项目 参考博客地址: ...