Spring Cloud (v): Hystrix monitor Panel "Finchley Version" Posted in 2018-04-16 | updated on 2018-05-10 |
In the previous Hystrix introduction, we mentioned that the circuit breaker is based on the request situation in a time window to determine and operate the circuit breaker open and closed state. The indicator information of these requests is the important metric information that the Hystrixcommand and Hystrixobservablecommand instances record during the execution, and they are very helpful to the system operation in addition to the use of the Hystrix circuit breaker implementation. These metrics information is aggregated in the form of "Scrolling time windows" and "buckets", and residing in memory for a period of time for internal or external query use, Hystrix Dashboard is one of the consumers of these metrics content.
Here we will use the Hystrix Dashboard to implement a visual panel of the Hystrix indicator data based on the previous example, here we'll take a few of the applications implemented before, including:
- Eureka-server: Service Registration Center
- Eureka-producer: Service Provider
- Eureka-consumer-feign-hystrix: Service consumers implemented with feign and hystrix
Create Hystrix Dashboard
Create a standard Spring Boot project named: Hystrix-dashboard
POM Configuration
Introduction of related dependencies in Pom.xml
Copy
1 2 3 4 5 6 7 8
|
<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> Span class= "line" ></DEPENDENCY> |
Start class
Introduce annotations on the start class of Spring boot @EnableHystrixDashboard
to enable the Hystrix Dashboard feature.
Copy
1 2 3 4 5 6 7 8
|
@EnableHystrixDashboard @SpringBootApplication hystrixdashboardapplication {
Main(string[] args) { Springapplication.run (Hystrixdashboardapplication.class, args); } }
|
Configuration file
Modifying a configuration file application.yml
Copy
1 2 3 4 5
|
Spring Application: Hystrix-dashboard Server 11000
|
Launch the app and then enter Http://localhost:11000/hystrix in the browser to see the following interface
Through the Hystrix Dashboard Main page of the text, we can know that Hystrix Dashboard a total of three different types of monitoring methods:
- Default cluster monitoring: Enable monitoring of the default cluster via Url:http://turbine-hostname:port/turbine.stream.
- Specified cluster monitoring: enabled by Url:http://turbine-hostname:port/turbine.stream?cluster=[clustername] to enable monitoring of the clustername cluster.
- Monitoring of monomer application: through Url:http://hystrix-app:port/hystrix.stream , it realizes the monitoring of a specific service instance. (now the URL here should be Http://hystrix-app:port/actuator/hystrix.stream,Actuator 2.x after the endpoints all
/actuator
under, can be management.endpoints.web.base-path
modified)
The first two of the cluster monitoring, need to integrate Turbine to achieve. In this section we first implement the monitoring of the monomer application, where the monomer application is using the service consumer--eureka-consumer-feign-hystrix we have previously implemented with feign and hystrix.
Two other parameters on the page:
- Delay: Controls the latency of the server polling for monitoring information by default of 2000 milliseconds, which can be configured to reduce client network and CPU consumption.
- Title: This parameter can be used to display the appropriate title.
Adding endpoint to a service instance
Since the Hystrix Dashboard monitoring Single Instance node needs to be implemented by accessing the interface of the instance /actuator/hystrix.stream
, naturally we need to add this endpoint to the service instance.
POM Configuration
pom.xml
Add a monitoring module to the node in the service instance dependencies
spring-boot-starter-actuator
to turn on the monitoring-related endpoint and ensure that the dependency of the circuit breaker has been introducedspring-cloud-starter-netflix-hystrix
Copy
1 2 3 4 5 6 7 8
|
<Dependency> <Groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-netflix-hystrix</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-actuator</artifactid> </dependency>
|
Start class
To add @EnableCircuitBreaker
or @EnableHystrix
annotate the startup class, turn on the circuit breaker function.
Copy
1 2 3 4 5 6 7 8 9
|
@EnableHystrix @EnableFeignClients @SpringBootApplication eurekaconsumerhystrixapplication {
Main(string[] args) { Springapplication.run (Eurekaconsumerhystrixapplication.class, args); } }
|
Configuration file
Add in configuration file application.yml
Copy
1 2 3 4 5
|
Management Endpoints: Web: Exposure Hystrix.stream
|
management.endpoints.web.exposure.include
This is used to expose the endpoints. Since endpoints contains many sensitive information, Web Access is not supported by default except for the health and info two support Web Access. Please see 50 for details. Endpoints
Test
Enter the Eureka-consumer-feign-hystrix corresponding address on the main interface of the Hystrix-dashboard Http://localhost:9004/actuator/hystrix.stream and click Monitor Stream button to enter the page.
If no request will always show "Loading ...", then access to Http://localhost:9004/actuator/hystrix.stream is also constantly showing "ping".
At this time to visit HTTP://LOCALHOST:9004/HELLO/WINDMT, you can see the Hystrix Dashboard appear similar to the following effect
If you see an error on this page: Unable to connect to Command Metric Stream.
, you can refer to this Issue solution.
Interface interpretation
The specific meanings of each of these elements are as follows:
- Solid Circle: It has color and size, which represent the monitoring degree and traffic size of the instance respectively. As shown, it decreases in health from green, yellow, orange, and red. With the display of this solid circle, we can quickly find fault instances and high-pressure instances in a large number of instances.
- Curve: Used to record the relative change of flow in 2 minutes, we can observe the rising and falling trend of traffic.
- Some other quantity indicators are as shown
The fuse monitoring to this single application has been completed.
Related reading
Spring Cloud (i): Overview of service governance Technologies
Spring Cloud (ii): Service Registration and Discovery Eureka
Spring Cloud (iii): service delivery and invocation Eureka
Spring Cloud (iv): Service-tolerant protection hystrix
Spring Cloud (v): Hystrix Monitor Panel
Spring Cloud (vi): Hystrix monitoring Data Aggregation Turbine
Spring Cloud (vii): Configuration Center (Git vs. dynamic refresh)
Spring Cloud (eight): Configuration Center (service and high availability)
Spring Cloud (ix): Configuration Center (message bus)
Spring Cloud (10): Service Gateway Zuul (routing)
Spring Cloud (11): Service Gateway Zuul (filter)
Spring Cloud (12): Distributed Link Tracking (Sleuth and Zipkin)
Sample code: GitHub
Reference
Springcloud (v): Fuse monitoring Hystrix Dashboard and Turbine
Spring Cloud builds a microservices architecture: Hystrix monitoring Panel "Dalston version"
Unable to connect to Command Metric Stream
- this article Yibo
- This article link: https://windmt.com/2018/04/16/spring-cloud-5-hystrix-dashboard/
- Copyright Notice: All articles in this blog are subject to the CC BY-NC-SA 4.0 license Agreement except for special statements. Reprint please specify the source!
Spring Cloud (v): Hystrix monitor Panel "Finchley Version"