1. 新建一个maven项目--导入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
2.设置端口号:
#配置项目端口号 server: port: 9001
3.在启动类上开启监控
@SpringBootApplication
@EnableHystrixDashboard //开启监控
public class DeptComsumerDashboard_9001 {
public static void main(String[] args) {
SpringApplication.run(DeptComsumerDashboard_9001.class,args);
}
}
以上基本完成监控,可以去 http://localhost:端口号/hystrix,如果出现以下画面,说明成功一半了
2大类,去哪监控 如服务端监控
1.在服务端一定要添加监控的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
3.在服务端的启动类上添加写死的bean
@Bean
public ServletRegistrationBean hystrixMetricsStreamServlet(){
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");
return servletRegistrationBean;
}
3.localhost:服务器的端口号/actuator/hystrix.stream ,将其复制到
4.添加delay时间,和title主题,然后点击monitor stream 进入页面
5.随意的访问服务端的各个接口,观察其变化⚪,和对应的颜色