Previous, using Feign fuse Hystrix, go to Consumer has been transformed, so that it has the ability to service exception handling.
The next step for visits to monitor service
Hystrix-dashboard fuse monitor, in real cluster nodes have many same services, just to make a single monitoring service node, cluster monitoring the next one will have to speak
Consumer consumers to transform
pom.xml new three-dependent
<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> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
Startup class
@SpringBootApplication @EnableDiscoveryClient @EnableFeignClients @EnableHystrixDashboard @EnableCircuitBreaker public class ApplicationStart { @Bean @LoadBalanced RestTemplate restTemplate(){ return new RestTemplate(); } @Bean public ServletRegistrationBean getServlet(){ HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); //监控实例 ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); //servlet注册接口 registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/actuator/hystrix.stream"); //路径 registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; } public static void main(String[] args) { SpringApplication.run(ApplicationStart.class); } }
1. Add comment
@EnableHystrixDashboard open fuse monitoring
@EnableCircuitBreaker open circuit breaker
2. Register servlet, is instantiated HystrixMetricsStreamServlet (need to add a newer version, low version skip)
Start Consumer, visit http: // localhost: 8051 / hystrix (8051 is my port side set in the application configuration file)
See this screen, indicating a successful start, here are three tips
Review the default cluster: http: // turbine-hostname: port / turbine.stream
View a specific cluster: http: // turbine-hostname: port / turbine.stream cluster = [clusterName]?
View this application: http: // hystrix-app: port / actuator / hystrix.stream
Now view only access to the present application, the output box enter: http: // localhost: 8051 / actuator / hystrix.stream, click on the monitor stream
If the loading, application access look at the address, my side is: http: // localhost: 8051 / message / remote / hello / there after the return to see
If you want to separate out the monitoring data, make their own warning, such as e-mail notification, SMS notification, you can call direct interface http: // localhost: 8051 / actuator / hystrix.stream, you can get