Hystrix Dashboard
Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix
Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。
Hystrix Dashboard模块代码实现
- POM
复制代码
1
2
3
4
5
6
7
8
9
10<!--hystrix dashboard--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency>
- yaml
复制代码
1
2
3server: port: 9001
- 主启动加
@EnableHystrixDashboard
注解
复制代码
1
2
3
4
5
6
7
8@SpringBootApplication @EnableHystrixDashboard public class DashBoardMain { public static void main(String[] args) { SpringApplication.run(DashBoardMain.class,args); } }
- 启动访问http://localhost:9001/hystrix/出现以下页面即成功
- 在需要监控的主启动类指定监控路径
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14@Bean public ServletRegistrationBean getServlet(){ HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); //注册Servlet ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean = new ServletRegistrationBean<>(streamServlet); //值越小,该servlet的优先级越高 registrationBean.setLoadOnStartup(1); //指定UrlMapping registrationBean.addUrlMappings("/hystrix.stream"); //指定name,如果不指定默认为dispatcherServlet registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
- 输入url地址点击下方按钮即可进入监控页面
服务监控页面
- 监控说明
最后
以上就是害羞镜子最近收集整理的关于SpringCloud Hystrix服务监控hystrixDashboard的全部内容,更多相关SpringCloud内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复