SpringCloud学习笔记(16)----Spring Cloud Netflix之Hystrix Dashboard+Turbine集群监控
前言:
上一节中,我们使用Hystrix Dashboard,只能看到单个应用内的服务信息。在生产环境中,我们经常是集群状态,所以我们需要用到Turbine这一应用。
作用:汇总系统内的多个服务的数据并显示到Hystrix Dashboard上。
1. 新建Turbine项目
添加依赖,pom文件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
2. 配置文件
# server
server.port=9998 # spring
spring.application.name=spring-cloud-turbine # eureka
#eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/ # info自定义
info.build.name=@project.name@
info.build.description=@project.description@
info.build.groupId=@project.groupId@
info.build.artifact=@project.artifactId@
info.build.version=@project.version@ eureka.instance.status-page-url-path=/info
eureka.instance.instanceId=${spring.application.name}:${random.value}
eureka.instance.prefer-ip-address=true #设置拉取服务注册信息时间,默认60s
eureka.client.registry-fetch-interval-seconds=30 #指定续约更新频率,默认是30s
eureka.instance.lease-renewal-interval-in-seconds=15 #设置过期剔除时间,默认90s
eureka.instance.lease-expiration-duration-in-seconds=45 # turbine(说明:注意必须为大写,因为eureka返回的值都是大写的)
turbine.aggregator.clusterConfig=SPRING-CLOUD-CONSUMER
turbine.app-config=spring-cloud-consumer
在项目启动类中添加@EnableTurbine注解。
3. 修改消费者servlet的映射路径
在2.x中,所有监控都会带上actuator根路径,所以我们需要修改消费者中HystrixMetricsStreamServlet注册时的映射路径,如下:
将原来的/hystrix.stream修改为/actuator/hystrix.stream即可
/**
* 配置Hystrix.stream的servlet
* @return
*/
@Bean
public ServletRegistrationBean registrationBean() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/actuator/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
4. 测试:如何监控一个集群应用
1. 启动三个不同端口的SPRING-CLOUD-CONSUMER.
2. 访问http://localhost:9999/hystrix
同时要监控9996,9997,9999三个端口
方法一:
分别加入http://localhost:9996/actuator/hystrix.stream,http://localhost:9997/actuator/hystrix.stream,http://localhost:9999/actuator/hystrix.stream三个路径。
方法二:
加入:http://localhost:9998/turbine.stream?cluster=SPRING-CLOUD-CONSUMER
说明:其中cluster对应配置文件中的clusterConfig的名称
3. 访问三个端口对应的服务,查看dashboard如下

这里有一个服务的断路器策略是线程池熔断策略,所以会显示线程池的信息。
5. 如何监控多个集群
1.在turbine中注释掉之前的配置,添加新的配置
turbine.aggregator.clusterConfig=WANGX
turbine.app-config=spring-cloud-consumer,spring-cloud-consumer2
turbine.cluster-name-expression=metadata['cluster']
turbine.combine-host-port=true
2. 在消费者中添加配置
eureka.instance.metadata-map.cluster=WANGX
在http://localhost:9999/hystrix中加入http://localhost:9998/turbine.stream?cluster=WANGX
此时会检测所有添加了数据源cluster的服务
6. 测试:监控全部应用
1. 在turbine中添加修改配置
保留
turbine.app-config=spring-cloud-consumer,spring-cloud-consumer2
修改
turbine.cluster-name-expression="default"
注释掉turbine.aggregator.clusterConfig=WANGX
#turbine.aggregator.clusterConfig=WANGX
在http://localhost:9999/hystrix中添加http://localhost:9998/turbine.stream
这样就可以对全部应用进行监控
SpringCloud学习笔记(16)----Spring Cloud Netflix之Hystrix Dashboard+Turbine集群监控的更多相关文章
- 断路器Hystrix与Turbine集群监控-Spring Cloud学习第三天(非原创)
文章大纲 一.Hystrix基础介绍二.断路器Hystrix简单使用三.自定义Hystrix请求命令四.Hystrix的服务降级与异常处理五.Hystrix的请求缓存与请求合并六.Hystrix仪表盘 ...
- SpringCloud学习笔记(15)----Spring Cloud Netflix之Hystrix Dashboard的使用
1. 引入依赖 在前面几节中的消费者中添加pom依赖. <dependency> <groupId>org.springframework.cloud</groupId& ...
- Spring Cloud Hystrix Dashboard熔断器-Turbine集群监控(六)
序言 上一篇说啦hystrix的使用方法与配置还有工作流程及为何存在,我去,上一篇这么屌,去看看吧,没这么屌的话,我贴的有官方文档,好好仔细看看 hystrix除啦基本的熔断器功能之外,还可以对接口的 ...
- spring cloud: Hystrix(八):turbine集群监控(dashboard)
turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群, 因此可以通过turbine来监控集群下hystrix的metrics情况,通过eur ...
- Kubernetes 学习笔记(二):本地部署一个 kubernetes 集群
前言 前面用到过的 minikube 只是一个单节点的 k8s 集群,这对于学习而言是不够的.我们需要有一个多节点集群,才能用到各种调度/监控功能.而且单节点只能是一个加引号的"集群&quo ...
- springCloud学习-消息总线(Spring Cloud Bus)
1.简介 Spring Cloud Bus 将分布式的节点用轻量的消息代理连接起来.它可以用于广播配置文件的更改或者服务之间的通讯,也可以用于监控.本文要讲述的是用Spring Cloud Bus实现 ...
- spring cloud:搭建基于consul的服务提供者集群(spring cloud hoxton sr8 / spring boot 2.3.4)
一,搭建基于consul的服务提供者集群 1,consul集群,共3个实例: 2, 服务提供者集群:共2个实例: 3,服务消费者:一个实例即可 4,consul集群的搭建,请参考: https://w ...
- spring cloud(Greenwich.M2) hystrix dashboard 报/actuator/hystrix.stream 404 Not Found的问题
consumer端不引用spring-boot-starter-actuator的情况 Consumer端会报Unable to connect to Command Metric Stream.新建 ...
- SpringCloud学习笔记(14)----Spring Cloud Netflix之Hystrix对Feign的支持
1. Hystrix对Feign的支持 添加Feign中IUserBiz的实现类HystrixFallBack: package com.wangx.cloud.springcloud02consum ...
随机推荐
- OpenCV3 安装
Opencv 安装 本文主要说明了在ubuntu上通过源码安装Opencv3,包含各种独立接口.具体可以参照LearnOpencv: https://www.learnopencv.com/insta ...
- CDR中如何将对象在页面居中显示
利用CorelDRAW在做设计排版时,如果想让对象在页面居中显示你会用什么方法?用鼠标拖?还是更准确的做法选择参照物对象,利用对齐与分布命令?或者还有更简单快速的方法,一起来看看吧! 最简单的方法(页 ...
- ZBrush国庆中秋大放价,优惠提前享!
没记错的话,上次的ZBrush活动应该是17年春节吧,悄么蔫地就把端午节等一系列节日忽略了,这让苦苦等待的小伙伴们情何以堪,这试用版用的也不得劲儿! 终于等到你,ZBrush官方消息称,17年中秋国庆 ...
- 如何保证 Linux 服务器的安全
如何保证 Linux 服务器的安全 2013/09/17 | 分类: IT技术 | 0 条评论 | 标签: LINUX, 服务器 分享到:53 本文由 伯乐在线 - 贾朝藤 翻译自 Spenser J ...
- [luogu] P4155 [SCOI2015]国旗计划(贪心)
P4155 [SCOI2015]国旗计划 题目描述 A 国正在开展一项伟大的计划 -- 国旗计划.这项计划的内容是边防战士手举国旗环绕边境线奔袭一圈.这项计划需要多名边防战士以接力的形式共同完成,为此 ...
- LeetCode 11. Container With Most Water 单调队列
题意 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai ...
- 【codeforces 812B】Sagheer, the Hausmeister
[题目链接]:http://codeforces.com/contest/812/problem/B [题意] 一个老大爷在一楼; 然后他有n楼的灯要关(最多n楼); 每楼有m个房间; 给出每个房间的 ...
- 工具-WIN7-内存占用过高解决办法
我的WIN7内存竟然吃到了7.6G,太不可思意了 第一步 看看网上的解决办法 http://jingyan.baidu.com/article/870c6fc31060eab03fe4beee.htm ...
- ASP.NET-表单验证-DataAnnotations
DataAnnotations [数据注解,数据注释] 需要引入两个脚本文件 <script src="@Url.Content("~/Scripts/jquery.val ...
- 洛谷 P2949 [USACO09OPEN]工作调度Work Scheduling
P2949 [USACO09OPEN]工作调度Work Scheduling 题目描述 Farmer John has so very many jobs to do! In order to run ...