文章目录
前言
hystrix-dashboard是对服务监控的可视化界面
1.新建dashborad工程,引入hystrix-dashborad相关依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.m.spring.cloud</groupId>
<artifactId>mservice-cloud-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- 将微服务provider侧注册进eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<!--hystrix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<!--hystrix dashboard-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
2.主启动类加入注解@EnableHystrixDashboard
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardMain_9001 {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardMain_9001.class,args);
}
}
3.在要监控的服务提供端加入配置,pom文件引入依赖
注意这里是springboot的依赖
<!--hystrix-dashboard需要监控的服务的依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
4.启动dashborad工程,访问http://localhost:9001/hystrix
5.访问监控页面
在输入框中输入要显示的监控服务地址页面
http://localhost:8001/hystrix.stream
localhost:80018001是服务提供方的地址
点击按钮