SpringCloud配置之:Turbine聚合监控
Turbine聚合监控
一、搭建监控模块
1. 创建监控模块
创建hystrix-monitor模块,使用Turbine聚合监控多个Hystrix dashboard功能,
2. 引入Turbine聚合监控起步依赖
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>hystrix-parent</artifactId><groupId>com.itheima</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion> <artifactId>hystrix-monitor</artifactId><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties> <dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-turbine</artifactId></dependency> <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-client</artifactId></dependency> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies> <build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build> </project>
3. 修改application.yml
spring:application.name: hystrix-monitor server:port: 8769 turbine:combine-host-port: true# 配置需要监控的服务名称列表app-config: hystrix-provider,hystrix-consumercluster-name-expression: "'default'"aggregator:cluster-config: default#instanceUrlSuffix: /actuator/hystrix.stream eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/
4. 创建启动类
@SpringBootApplication @EnableEurekaClient @EnableTurbine //开启Turbine 很聚合监控功能 @EnableHystrixDashboard //开启Hystrix仪表盘监控功能 public class HystrixMonitorApp { public static void main(String[] args) {SpringApplication.run(HystrixMonitorApp.class, args);} }
二、修改被监控模块
需要分别修改 hystrix-provider 和 hystrix-consumer 模块:
1、导入依赖:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency>
2、配置Bean
此处为了方便,将其配置在启动类中。
@Beanpublic ServletRegistrationBean getServlet() {HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);registrationBean.setLoadOnStartup(1);registrationBean.addUrlMappings("/actuator/hystrix.stream");registrationBean.setName("HystrixMetricsStreamServlet");return registrationBean;}
3、启动类上添加注解@EnableHystrixDashboard
@EnableDiscoveryClient
@EnableEurekaClient
@SpringBootApplication
@EnableFeignClients
@EnableHystrixDashboard // 开启Hystrix仪表盘监控功能
public class ConsumerApp {
public static void main(String[] args) {SpringApplication.run(ConsumerApp.class,args);}@Beanpublic ServletRegistrationBean getServlet() {HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);registrationBean.setLoadOnStartup(1);registrationBean.addUrlMappings("/actuator/hystrix.stream");registrationBean.setName("HystrixMetricsStreamServlet");return registrationBean;}
}
三、启动测试
1、启动服务:
eureka-server
hystrix-provider
hystrix-consumer
hystrix-monitor
2、访问:
在浏览器访问http://localhost:8769/hystrix/ 进入Hystrix Dashboard界面
界面中输入监控的Url地址 http://localhost:8769/turbine.stream,监控时间间隔2000毫秒和title,如下图
实心圆:它有颜色和大小之分,分别代表实例的监控程度和流量大小。如上图所示,它的健康度从绿色、黄色、橙色、红色递减。通过该实心圆的展示,我们就可以在大量的实例中快速的发现故障实例和高压力实例。
曲线:用来记录 2 分钟内流量的相对变化,我们可以通过它来观察到流量的上升和下降趋势。
SpringCloud配置之:Turbine聚合监控相关推荐
- SpringCloud系列七:Hystrix 熔断机制(Hystrix基本配置、服务降级、HystrixDashboard服务监控、Turbine聚合监控)...
声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅. 1.概念:Hystrix 熔断机制 2.具体内容 所谓的熔断机制和日常生活中见到电路保险丝是非常相似的,当出现了问题之后,保险丝 ...
- SpringCloud:Hystrix 熔断机制(基本配置、服务降级、HystrixDashboard服务监控、Turbine聚合监控)
所谓的熔断机制和日常生活中见到电路保险丝是非常相似的,当出现了问题之后,保险丝会自动烧断,以保护我们的电器, 那么如果换到了程序之中呢?当现在服务的提供方出现了问题之后整个的程序将出现错误的信息显示, ...
- 使用Turbine聚合监控数据
一.使用Turbine聚合监控数据 使用/hystrix.stream端点监控单个微服务实例.然而,使用微服务架构的应用系统一般会包含若干微服务,每个微服务通常都会部署多个实例.如果每次只能查看单个实 ...
- Turbine聚合监控
Turbine聚合监控 一.搭建监控模块 1. 创建监控模块 创建hystrix-monitor模块,使用Turbine聚合监控多个Hystrix dashboard功能, 2. 引入Turbine聚 ...
- 使用Turbine聚合监控
Turbine概述 Turbine真正做的,就是将每一个(指定)服务的Hystrix/stream中的状态信息取出,并集中处理(计算与展示),应该说,它是具有自己独立的调度的,服务(实例)发现,服务连 ...
- Hystrix Turbine聚合监控
之前,我们针对的是一个微服务实例的Hystrix数据查询分析,在微服务架构下,一个微服务的实例往往是多个(集群化). 比如自动投递微服务 实例1(hystrix) ip1:port1/actuator ...
- 使用 Turbine 聚合监控
在使用 Hystrix Dashboard 组件监控服务的熔断状况时,每个服务都有一个 Hystrix Dashboard 主页,当服务数量很多时相当不方便.为了同时监控多个服务的熔断器的状态,可以使 ...
- 史上最简单的SpringCloud教程 | 第十三篇: 断路器聚合监控(Hystrix Turbine)
转:https://blog.csdn.net/forezp/article/details/70233227 上一篇文章讲述了如何利用Hystrix Dashboard去监控断路器的Hystrix ...
- spring cloud之Turbine断路器聚合监控(十二)
一.博客背景 上一章讲解了针对一个微服务的断路器监控,但是微服务通常会是多个实例组成的一个集群. 倘若集群里的实例比较多,难道要挨个挨个去监控这些实例吗? 何况有时候,根据集群的需要,会动态增加或者减 ...
最新文章
- 干货:NIST评测(SRE19)获胜团队声纹识别技术分析 | CSDN博文精选
- JavaScript在离开页面是提示用户
- 06_基本的图像分类案例、导入图片数据、探索数据的格式、数据预处理、构建模型(设置层、编译模型)、训练模型(Fit模型、评估精确度)、得出预测结果(验证预测结果)、使用训练过的模型
- linux命令编写四位数密码本,grub-crypt命令 – 对口令进行加密
- 使用C#开发ActiveX控件
- java锁的粗化,锁优化(自旋锁,锁消除,锁粗化,轻量级锁,偏向锁)(深入理解JAVA虚拟机-学习记录)...
- 2021上海交大网络安全保研夏令营经验
- 决策树中的基尼系数、 熵之半和分类误差率
- VMware 15.5.7 的下载与安装
- 为什么有的人飞黄腾达,有的人穷困潦倒 .
- note 8 字符串
- Kaiming He 何恺明
- hacks cheats injection
- 薄膜检测有哪些工艺流程,快来做功课
- Elliptic Labs 与世界领先的笔记本电脑OEM签署首份企业软件许可合同
- 怎么用计算机算自己的月经周期,【月经周期表】月经周期表计算器_女人月经周期表 - 妈妈网百科...
- 下载网盘资源如何更快呢?
- 如何移除Chrome浏览器让人不爽的GoogleUpdate.exe后台更新进程
- 常见浏览器User-Agent大全(转载)
- Discuz如何开发关注功能