hystrix-dashboard熔断器的可视化界面
hystrix-dashboard熔断器的可视化界面的实现如下
在pom中引入依赖
spring-cloud-starter-netflix-hystrix-dashboard
spring-boot-starter-actuator

在启动类加上EnableHystrixDashboard注解,在spring boot 2.X还要加上这段配置
@Bean
public ServletRegistrationBeangetServlet() {
HystrixMetricsStreamServlet streamServlet =new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean =new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}

配置文件中还要加上这个配置
management:
context-path: /

启动order服务,打开这个地址就能访问可视化界面了

我是按照下面的输入进去,点击按钮进入参数页

请求order服务的接口,就会出现下面的数据


曲线中间有个圆,圆的大小表示流量,流量越大,圆越大;颜色越偏向红色,代表这个服务越不健康。
图中testHystrixCommand5下来的百分比是失败率,旁边的六个数字根据颜色不同分别对应右上角那里的Success | Short-Circuited | Bad Request | Timeout | Rejected | Failure 的颜色,
Host就是请求的频率
Circuit就是熔断的状态,open就是熔断打开,closed就是关闭,还有半开half open
曲线代表一段时间内,流量的相对变化
还有其他参数就不在这里一一列出了,看看官方文档的介绍吧。
本次代码在:https://github.com/hmilyos/springCloud-order.git hystrixDashboard 分支