Introduction to Hystrix Dashboard
The Hystrix dashboard allows you to monitor Hystrix metrics in real time.
When you can use this dashboard, you can improve its operations by reducing the time required to discover and recover operational events. The duration of most production events (which are less frequent due to Hystrix) has become shorter and the impact has been reduced. This is because the Hystrix dashboard provides real-time insight into system behavior.
Hystrix provides monitoring information on the status of microservice calls, but it needs to be used in conjunction with the spring-boot-actuator module. Hystrix Dashboard is a component of Hystrix. Hystrix Dashboard provides a circuit breaker monitoring panel, which allows us to better monitor the status of services and clusters.
Hystrix dashboard use
Build Hystrix dashboard project
1. New project (test-springcloud-hystrix7979), introducing dependencies:
1 <!-- hystrix-dashboard --> 2 <dependency> 3 <groupId>org.springframework.cloud</groupId> 4 <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> 5 </dependency>
The complete pom file is as follows:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <parent> 6 <artifactId>test-springcloud</artifactId> 7 <groupId>com.test</groupId> <8 version>1.0-SNAPSHOT</version> 9 </parent> 10 <modelVersion>4.0.0</modelVersion> 11 12 <artifactId>test-springcloud-hystrix7979</artifactId> 13 14 <dependencies> 15 16 <!-- hystrix-dashboard --> 17 <dependency> 18 <groupId>org.springframework.cloud</groupId> 19 <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> 20 </dependency> 21 22 <!-- spring boot --> 23 <dependency> 24 <groupId>org.springframework.boot</groupId> 25 <artifactId>spring-boot-starter-web</artifactId> 26 </dependency> 27 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-actuator</artifactId> 31 </dependency> 32 33 34 <dependency> 35 <groupId>org.springframework.boot</groupId> 36 <artifactId>spring-boot-devtools</artifactId> 37 <scope>runtime</scope> 38 <optional>true</optional> 39 </dependency> 40 41 <dependency> 42 <groupId>org.projectlombok</groupId> 43 <artifactId>lombok</artifactId> 44 <optional>true</optional> 45 </dependency> 46 <dependency> 47 <groupId>org.springframework.boot</groupId> 48 <artifactId>spring-boot-starter-test</artifactId> 49 <scope>test</scope> 50 </dependency> 51 52 </dependencies> 53 54 <build> 55 <finalName>test-springcloud-hystrix7979</ finalName> 56 </build> 57 58 </project>
2. Write application.yml configuration file
1 # Port 2 Server: 3 Port: 7979
3. Write the main startup class and use the @EnableHystrixDashboard annotation to open HystrixDashboard
1 // 开启HystrixDashboard 2 @EnableHystrixDashboard 3 @SpringBootApplication 4 public class HystrixMain7979 { 5 public static void main(String[] args) { 6 SpringApplication.run(HystrixMain7979.class, args); 7 } 8 }
4. Start the project
Visit address: http: // localhost: 7979 / hystrix
Up to this Hystrix dashboard project, the construction is completed
Monitor Hystrix service items
1. Use the project from the previous chapter to ensure that the Hystrix service project (test-springcloud-provider-payment8008) has dependencies as follows:
1 <!-- hystrix --> 2 <dependency> 3 <groupId>org.springframework.cloud</groupId> 4 <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> 5 </dependency> 6 7 <dependency> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId>spring-boot-starter-actuator</artifactId> 10 </dependency>
2. Add the following content to the configuration file and start the "hystrix.stream" port
1 management: 2 endpoints: 3 web: 4 exposure: 5 include: health,info,hystrix.stream
3. Start the project test
1) Access address: http: // localhost: 8008 / actuator / hystrix.stream
2) Enter the monitoring address on the Hystrix dashboard: http: // localhost: 8008 / actuator / hystrix.stream
3) Click Monitor Stream to enter the following interface and use JMeter to request Hystrix services:
Description:
Circle: Healthy color, decreasing from green, yellow, orange, red
Circle: the larger the flow, the larger the solid circle
Color numbers: statistical values for each result of request processing