文章目录
1. 说明
Hystrix Dashbord是一个监控模块,用来监控Hystrix的各项指标。这边文章使用的spring cloud的Finchley版本,Hystrix的的调用信息不再是http://hystrix-app:port/hystrix.stream,而是变为了http://hystrix-app:port/actuator/hystrix.stream,另外由于 endpoints 中会包含很多敏感信息,除了 health 和 info 两个支持 web 访问外,其他的默认不支持 web 访问,需要在yml配置文件中配置开启
官网
博文
2. 搭建Dashbord仪表盘项目
2.1 pom依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--Finchley版本的hystrix需要加上netflix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
</dependencies>
2.2 yml配置
server:
port: 10001
2.3 主启动类
@SpringBootApplication
@EnableHystrixDashboard
public class EurekaConsumeHystrixDashbord10001 {
public static void main(String[] args) {
SpringApplication.run(EurekaConsumeHystrixDashbord10001.class, args);
}
}
2.4 测试
访问http://localhost:10001/hystrix会出现下面页面
这时候访问http://hystrix-app:port/actuator/hystrix.stream是访问不通的,需要改造使用Hystrix的Consumer项目
3 改造Consumer
3.1 增加依赖
Consumer项目需要actuator的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
3.2 yml配置
配置文件打开stream的endpoints
management:
endpoints:
web:
exposure:
include: hystrix.stream
3.3 测试
http://localhost:9001/actuator/hystrix.stream会出现ping的界面表示成功
4. 监控项目
进入仪表盘项目首页http://localhost:10001/hystrix,输入需要监控的消费者的/autuator/hystrix.stream路径即可
然后就可以看到监控页面
关于监控器的指标可以查看下图