概述:
除了隔离依赖服务的调用外,Hystrix还提供了准实时的调用监控(Hystrix Dashboard),Hystrix会持续地记录所有通过Hystrix发起的请求执行信息,并以统计报表和图形展示给用户,包括每秒执行多少请求多少成功,多少失败等等,Netflix 通过hystrix-metrics-event-stream项目,实现了对以上指标的监控,SpringCloud也提供了HystrixDashboard的整合,对监控内容转化成可视化界面;
pom依赖:
<dependency>
<groupId>org.springframework.cloud<groupId>
<artifactId>spring-cloud-starter-netflix-dashboard<artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot<groupId>
<artifactId>spring-boot-starter-actuator<artifactId>
<dependency>
主启动类@EnableHystrixDashboard
yml 配置端口号
所有监控的客户端都需要actuator 依赖
被监控的客户端主启动类加如下配置:
@Bean
public ServletRegistrationBean getServlet(){
HystrixMetricsStreamServlet streamservlet = new HystrixMetricStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet)
registrationBean.setLoadOnStartUp(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet")
;
return registrationBean;
}