阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

实现数据的可视化监控

120次阅读
没有评论

共计 1501 个字符,预计需要花费 4 分钟才能阅读完成。

1、用 Hystrix Dashboard 实现数据的可视化监控

除容错处理外,Hystrix 还提供了实时的监控,它会实时、累加地记录所有关于 HystrixCommand 的执行信息,包括每秒执行了多少请求、请求有多少次成功多少次失败等。

HystrixDashboard 是一款针对 Hystrix 进行实时监控的工具。HystrixDashboard 可以可视地查看实时监控数据,可以直观地显示出各 Hystrix Command 的请求响应时间、请求成功率等数据。

1.1、添加依赖和配置

<!--Hystrix 的依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> <version>1.2.6.RELEASE</version> </dependency> <!--Actuator 依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!--Hystrix 依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> <version>2.0.1.RELEASE</version> </dependency>

1.2、配置启动 Servlet

@EnableFeignClients @SpringBootApplication @EnableDiscoveryClient @EnableHystrixDashboard @EnableCircuitBreaker public class HystrixSpringcloudApplication {public static void main(String[] args) {SpringApplication.run(HystrixSpringcloudApplication.class, args); } @Bean public ServletRegistrationBean getServlet(){HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/actuator/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; } }

1.3、查看监控数据

1、启动项目,然后访问 http://localhost:50007/hystrix。

2、在监控路径输入框中输入 http://localhost:50007/actuator/hystrix.stream, 即可进入监控页面查看监控数据。

实现数据的可视化监控

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-06-06发表,共计1501字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中