您的位置:首页 > 编程语言 > Java开发

Spring Cloud学习--容错机制(Hystrix DashBoard之数据监控)

2017-10-01 20:36 543 查看
本文目录:

一使用Actuator监控

二 使用Hystrix DashBoard监控

一、使用Actuator监控

除了实现容错功能,Hystrix还提供了近乎实时的监控。断路器的状态也会暴露在Actuator提供的/health端点中,只需为项目(该项目可见http://blog.csdn.net/u012482647/article/details/78148447)添加spring-boot-actuator,重启项目,先访问http://localhost:8777/getString 再访问http://localhost:8777/hystrix.stream ,即可看到实时的监控数据。

因我使用火狐浏览器,每次访问就是下载hystrix.stream文件。这个问题还没解决,望各位大神支支招。

二 、使用Hystrix DashBoard监控

Actuator 能看到的是一大堆数据,而使用Hystrix DashBoard(仪表盘),使得监控数据图形化、可视化。Hystrix仪表板可以显示每个断路器(被@HystrixCommand注解的方法)的状态。步骤如下:

1.创建一个基本的spring boot 工程,添加spring-cloud-starter-hystrix-dashboard依赖。

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>


2.启动类上添加@EnableHystrixDashboard 注解

@EnableHystrixDashboard
@SpringBootApplication
public class SpringCloudHystrixDashboardApplication {

public static void main(String[] args) {
SpringApplication.run(SpringCloudHystrixDashboardApplication.class, args);
}
}


4.配置文件:

spring.application.name=hystrix-Dashboard
server.port=2001


3.启动项目,访问http://localhost:2001/hystrix 这是Hystrix DashBoard监控首页。



在url中输入http://localhost:8777/hystrix.stream ,点击Monitor Stream 出现如图界面,数量指标如图所示:



综上,实现了利用Hystrix DashBoard对单个实例的信息监控。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring-cloud java
相关文章推荐