1. 程式人生 > >Hystrix-Dashboard介紹+案例+圖分析

Hystrix-Dashboard介紹+案例+圖分析

測試中使用到的程式碼到在這裡https://download.csdn.net/download/zhou920786312/10853300

Hystrix-Dashboard介紹

 

  • 實時監控Hystrix的各項指標資訊
  • 是Hystrix的儀表盤元件
  • 可以快速發現系統中存在的問題
  • 通過實時監控來動態修改配置,直到滿意為止
  • 總而言之:就是頁面監控工具

案例

microservicecloud-consumer-hystrix-dashboard-9001


@SpringBootApplication
//開啟HystrixDashboard
@EnableHystrixDashboard


public class DeptConsumer_DashBoard_App_9001
{
    public static void main(String[] args)
    {
        SpringApplication.run(DeptConsumer_DashBoard_App_9001.class, args);
    }
}

 

 

<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.atguigu.springcloud</groupId>
    <artifactId>microservicecloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>microservicecloud-consumer-hystrix-dashboard-9001</artifactId>
  
 <dependencies>
		<!-- 自己定義的api -->
		<dependency>
			<groupId>com.atguigu.springcloud</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>

 

 

測試1-啟動監控服務

如果如下面顯示,表示監控程式啟動成功。

http://localhost:9001/hystrix

 

 

測試2-啟動監控服務+被監控的服務+3個eureka

microservicecloud-consumer-hystrix-dashboard-9001

microservicecloud-provider-dept-hystrix-8001

   microservicecloud-provider-dept-hystrix-8001的POM

 <!-- actuator監控資訊完善 與Hystrix-Dashboard配合使用-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

檢視8001服務

方式1

 

方式2

 

 

 

圖分析