我是靠谱客的博主 害羞镜子,这篇文章主要介绍SpringCloud Hystrix服务监控hystrixDashboard,现在分享给大家,希望可以做个参考。

Hystrix Dashboard

Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix
Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。

Hystrix Dashboard模块代码实现

  1. 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>
  1. yaml
复制代码
1
2
3
server: port: 9001
  1. 主启动加@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); } }
  1. 启动访问http://localhost:9001/hystrix/出现以下页面即成功
    在这里插入图片描述
  2. 在需要监控的主启动类指定监控路径
复制代码
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; }
  1. 输入url地址点击下方按钮即可进入监控页面
    在这里插入图片描述
    服务监控页面
    在这里插入图片描述
  2. 监控说明
    在这里插入图片描述

最后

以上就是害羞镜子最近收集整理的关于SpringCloud Hystrix服务监控hystrixDashboard的全部内容,更多相关SpringCloud内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部