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 ...
随机推荐
- Django开发之路 一(django安装并测试运行)
安装Django与测试 1.虚拟环境的安装 一般来说Django的开发最好是在虚拟环境上进行,这样的好处是可以将不同的Django的项目的环境分割开来,相互不影响.比如说项目一用到Python2.x和 ...
- vc6中关于“新建”
1.windows api 编程:新建→工程→Win32 Application→一个空工程→新建→文件→C++ Source File2.windows mfc 编程:新建→工程→MFC AppWi ...
- Paper-[arXiv 1710.03144]Island Loss for Learning Discriminative Features in Facial Expression
[arXiv 1710.03144]Island Loss for Learning Discriminative Features in Facial Expression ABSTRACT 作者在 ...
- 0-NULL-nullptr
NULL In C A null-pointer constant is an integral constant expression that evaluates to zero (like 0 ...
- 页面定制CSS代码初探(四):cnblogs使用Github引用样式
前言 对于用惯了Github的人来说,眼里的引用应该是这样的 "Talk is cheap. Show me the code" -- Linus Torvalds 然而实际上cn ...
- Unity3d 拖拽脚本报错 Can’t add script
报错截图: 报错原因: c#文件创建以后再改名,会报错找不到对应类. 类名和文件名要一致才行.(这个是Unity要求,c#本身不要求一致)
- phpMyAdmin 高级功能尚未完全设置,部分功能未激活(转载)
phpMyAdmin 高级功能尚未完全设置,部分功能未激活.请点击这里查看原因. 第一步: 使用Mysql管理员帐号通过phpmyadmin登陆,然后点击“导入”,然后点击“浏览”按钮,找到phpmy ...
- HBase入门操作 常用命令和增删改查的简单应用操作
这里启动关闭Hadoop和HBase的顺序一定是: 启动Hadoop—>启动HBase—>关闭HBase—>关闭Hadoop ssh localhost 开启hadoopcd /us ...
- vue 阿里云上传组件
vue 阿里云上传组件 Vue.js上传图片到阿里云OSS存储 测试项目git地址 本测试项目启动方法 示例链接 组件配置项 实践解释 本文主要介绍如何 在vue项目中使用web 直传方式上传阿里云o ...
- python学习笔记:第三天
day03: 1.python中所有的变量都可以改变 2.Print(name) 打印 3.Del name 删除 4.python中python2与python3不能兼容,需要分别安装pyth ...