SpringCloud---HystrixDashboard 使用(8)

x33g5p2x  于2021-12-18 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(239)

除了隔离依赖服务的调用以外,Hystrix还提供了准实时的监控(Hystrix Dashboard)Hystrix会持续记录所有通过Hystrix发起的请求的执行信息并以统计报表和图形的形式展示给用户,包括每秒执行多少请求多少成功,多少失败等,Netflix通过一个项目实现监控,springcloud也提供了Hystrix Dashboard 的整合,对监控内容转化成可视化界面

创建一 个 Dashboard 的项目、
1)

dashboard依赖

<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
		</dependency>

pom文件

<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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.xxx</groupId>
    <artifactId>microservicecloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>microservicecloud-consumer-hystrix-dashboard</artifactId>
  
<dependencies>
		<!-- 自己定义的api -->
		<dependency>
			<groupId>com.xxx</groupId>
			<artifactId>microservicecloud-api</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<!-- 修改后立即生效,热部署 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>springloaded</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>
		<!-- Ribbon相关 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-ribbon</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<!-- feign相关 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-feign</artifactId>
		</dependency>
		<!-- hystrix和 hystrix-dashboard相关 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-hystrix</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
		</dependency>
	</dependencies>
</project>

.yml 文件

就是个端口号

server:
  port: 8086

启动类

@EnableHystrixDashboard 开启dashboard

package com.xxx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;

@SpringBootApplication
@EnableHystrixDashboard
public class UserDashboardApp {

  public static void main(String[] args) {

	  SpringApplication.run(UserDashboardApp.class, args);
	  
}
	
}

启动项目 开一下是否成功
http://127.0.0.1:8086/hystrix
启动成功打开的页面见下下图

下面 启动 eureka集群(7001,7002,7003)–》提供者(microservicecloud-provider-dept-hystrix-8085)—》监控者( microservicecloud-consumer-hystrix-dashboard)5个项目

1)需要监控的项目的后缀hystrix.stream

2)提供者

3)回到Dashboard 页面

点进去会出现图形界面

代表 含义解析

实心圆:共有两种含义,他通过颜色的变化代表了实例的健康,他的健康度从绿色<黄色<橙色<红色递减,该实心圆除了颜色之外,他的大小也会 根据实例的请求流量发生 改变,流量越大实心圆就越大,所以通过实心圆的展示,就可以在大量的实例中快速的发现故障实例和 高压实例

我 现在呢 去 刷新几次提供者microservicecloud-provider-dept-hystrix-8085 就可 更好的理解

相关文章