目录
一、概述
二、 搭建
1、新建模块
2、修改pom文件
3、编写yml文件
4、编写主启动类(要加上@EnableHystrixDashboard注解)
5、在所有微服务模块(8001、8002...)配置监控依赖
6、运行
三、实战(监控8001模块)
1、在8001的主启动类中增加配置
2、将8001的地址填写到豪猪哥中
3、点击监控(Monitor Stream)
4、监控界面如何看懂
一、概述
二、 搭建 1、新建模块除了隔离依赖服务的调用以外,Hystrix还提供了准实时的调用监控(Hystrix Dashboard),Hystrix会持续地记录所有通过Hystrix发起的请求的执行信息,并以统计报表和图形的形式展示给用户,包括每秒执行多少请求多少成功,多少失败等。Netflix通过hystrix-metrics-event-stream项目实现了对以上指标的监控。Spring Cloud也提供了Hystrix Dashboard的整合,对监控内容转化成可视化界面。
新建普通maven模块 cloud-consumer-hystrix-dashboard9001
2、修改pom文件3、编写yml文件cloud com.shang.cloud 1.0-SNAPSHOT 4.0.0 cloud-consumer-hystrix-dashboard9001org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboardorg.springframework.boot spring-boot-starter-actuatororg.springframework.boot spring-boot-devtoolsruntime true org.projectlombok lomboktrue org.springframework.boot spring-boot-starter-testtest 8 8
server: port: 90014、编写主启动类(要加上@EnableHystrixDashboard注解)
@SpringBootApplication @EnableHystrixDashboard public class HystrixDashboardMain9001 { public static void main(String[] args) { SpringApplication.run(HystrixDashboardMain9001.class, args); } }5、在所有微服务模块(8001、8002...)配置监控依赖
6、运行org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-actuator
浏览器地址栏输入 http://localhost:9001/hystrix
显示出豪猪哥说明搭建成功
三、实战(监控8001模块) 1、在8001的主启动类中增加配置
@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; }
2、将8001的地址填写到豪猪哥中
http://localhost:8001/hystrix.stream
3、点击监控(Monitor Stream)
可以看到监控界面
4、监控界面如何看懂
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)