SpringCloud demo---Hystrix Dashboard
1.概念
Hystrix Dashboard 是 Hystrix 的仪表盘组件,提供了数据监控,可以实时监控 Hystrix 的各个指标,然后通过图形化界面展示出来。
2.hystrix-dashboard
2.1 配置文件
server:
port: 8767
spring:
application:
name: spring-cloud-hystrix-dashboard
2.2 注解和依赖
添加依赖:spring-cloud-starter-netflix-hystrix ;spring-cloud-starter-netflix-hystrix-dashboard ;spring-boot-starter-actuator
添加注解:@EnableHystrixDashboard
2.3 在ribbon服务中添加相关配置
2.3.1 添加依赖:spring-cloud-starter-netflix spring-boot-starter-actuator spring-cloud-starter-netflix-hystrix-dashboard
2.3.2 添加注解:@EnableCircuitBreaker,上面已经完成hystrix的配置
2.3.3 在配置文件中加入一下配置:
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
2.4 访问地址
2.4.1 访问地址http://localhost:8764/actuator/hystrix.stream,可以发现一只在Ping,在访问ribbon服务端的接口后返回了data
2.4.2 访问http://localhost:8767/hystrix,添加上述地址,并访问服务端接口后可以出现图形化界面
2.4 3 Unable to connect to Command Metric Stream问题:
springboot版本2.0以上,加上上述依赖即可。不需要加入下面的servlet:
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}

浙公网安备 33010602011771号