Hystrix 仪表盘:Hystrix Dashboard
Hystrix可视化监控。
仪表盘服务搭建
依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
开启监控版面
@SpringBootApplication
@EnableHystrixDashboard //开启监控面板
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
进入可视化界面
进入可视化界面后,需输入需要监控的连接,获取信息的延迟,标题等。
仪表盘BUG解决
按照官方提供的 https://hystrix-app:port/actuator/hystrix.stream 输入连接,无法获取到服务的数据,我们需要到需要被监控的服务中添加如下配置,输入的url被修改成这样的格式: https://hystrix-app:port/hystrix.stream
@Bean //放到被监控的服务里面`
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
进去了之后依然无法获取到数据,一直显示Loading
新版本中springcloud将jquery版本升级为3.4.1,jquery 3.4.1已经废弃这样的语法:(window).load(function()替换为$(window).on("load",function(),即可。
输入要监控后服务后:
发送了10个请求,10个请求都会使得后端报错,从而熔断,监控界面如图: