Building a Hystrix dashboard in spring cloud is very simple and requires only the following four steps:
Create a standard spring boot project named: Hystrix-dashboard.
Edit Pom.xml, depending on the content as follows:
<parent><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-parent</artifactId><version>Dalston.SR1</version><relativePath /></parent><dependencies><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><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency></dependencies>
To apply the main class plus @enablehystrixdashboard, enable the Hystrix dashboard feature.
@EnableHystrixDashboard@SpringCloudApplicationpublic class HystrixDashboardApplication {public static void main(String[] args) {SpringApplication.run(HystrixDashboardApplication.class, args);}}
Modify the Application.properties configuration file according to the actual situation, such as: Select an unoccupied port, etc., this step is not required.
spring.application.name=hystrix-dashboardserver.port=1301
Since the Hystrix dashboard monitoring Single instance node needs to be implemented by accessing the/hystrix.stream interface of the instance, naturally we need to add this endpoint for the service instance, and the steps to add that feature are just as simple as the following two steps:
Add a Spring-boot-starter-actuator monitoring module to the Dependencies node in the service instance Pom.xml to turn on the monitoring-related endpoint and ensure that the dependency Spring-cloud-starter-hystrix for the circuit breaker has been introduced:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-hystrix</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
Ensure that the @enablecircuitbreaker or @enablehystrix annotations have been used in the main class of the service instance to turn on the circuit breaker function.
Spring Cloud builds a microservices architecture Hystrix monitoring Panel