当前位置:网站首页>Turbine聚合监控
Turbine聚合监控
2022-07-29 15:35:00 【大梦谁先觉i】
一、搭建监控模块
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.test</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-consumer
cluster-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
此处为了方便,将其配置在启动类中。
@Bean
public 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);
}
@Bean
public 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 分钟内流量的相对变化,我们可以通过它来观察到流量的上升和下降趋势。
边栏推荐
- 使用DataEase开源工具制作一个高质量的数据大屏
- Impala时间函数总结
- 金九银十必备 快来看看你还缺啥
- Jenkins持续集成与自动化部署系统安装配置
- BGP联邦实验
- The future trend of the conversation
- Unable to open the source file in qt vs2015 "QtWidgets" solution
- 展讯模块读写IMEI
- This article penetrates the architecture design and cluster construction of the distributed storage system Ceph (hands-on)
- File management: logical structure
猜你喜欢
AI全流程开发难题破解之钥
最新!多交的税可以退,同学,你今天退税了吗?
【深度学习】深度学习刷SOTA的一堆trick
如何创建NFT(还在创作中ing)
Property (Property Animation Animation), the basic use of Butterknife butter knife
mysql的union和union all
半导体行业集团采购管理系统:简化企业采购流程,以数字化畅通采购信息渠道
【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)-- 组件UI
双非渣渣的上岸之路!备战 60 天,三战滴滴侥幸收获 Offer
QT连接Mysql数据库(详细成功版)
随机推荐
ES6 from entry to master # 10: Set the Set data type
SAP ABAP OData 服务诊断工具 /IWFND/ERROR_LOG 的使用方法试读版
边缘计算如何与小程序结合?智能家居如何借势发展?
VMware 16.1软件安装包下载及安装教程
稳稳当当的生活
BGP federation experiment
开源数据库连接池的使用及其工具类
浏览器线程
Face key point prediction and normalization
如何检测出你们安装的依赖是否安全
奇怪,为什么ArrayList初始化容量大小为10?
Detailed evaluation of Renesas RZ/G2L processor
PHP 读取/导出 CSV文件
药品研发--质理研究人员绩效办法
使用DataEase开源工具制作一个高质量的数据大屏
数商云SCM供应链系统方案服务亮点:生产管理更智能、产业供应链协同管理更便捷
数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级
Comparator和Comparable
See you in shenzhen!Cloud native to accelerate the application building special: see cloud native FinOps, SRE, high-performance computing scenario best practices
深圳见!云原生加速应用构建专场:来看云原生 FinOps、SRE、高性能计算场景最佳实践