开启feign 熔断 hystrix    整合hystrix-dashboard监控面板

1. 服务调用者boot工程 pom引入依赖

<!-- hystrix-dashboard 监控依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

  

2. 启动类开启熔断注解 @EnableCircuitBreaker  面板监控注解 @EnableHystrixDashboard  添加面板servlet

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker
@EnableHystrixDashboard
public class WebWapApplication { public static void main(String[] args) {
SpringApplication.run(WebWapApplication.class, args);
} @Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
} @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;
} }

  

3.修改配置文件  开启feign熔断  设置超时时间

feign.hystrix.enabled=true
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=20000

  

4.浏览器查看面板监控   http://localhost:8080/hystrix

点击Monitor Stream   可查看请求成功次数   超时次数  等等

整合多个服务  分布式监控   使用 Turbine

1.新建boot工程  引入依赖

 <!-- eureka客户端  -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency> <!-- hystrix 监控面板 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency> <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>

2.启动类添加注解

  

@SpringBootApplication
@EnableEurekaClient
@EnableHystrixDashboard
@EnableTurbine
public class HystrixDashboardApplication { public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
} @Bean
public ServletRegistrationBean getServlet(){
HystrixMetricsStreamServlet streamServlet=new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean=new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
}

  

3. 配置文件

server.port=9004
spring.application.name=hystrix-dashboard
#eureka
eureka.client.service-url.defaultZone=http://localhost:9001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port} management.endpoints.web.exposure.include=hystrix.stream,health,info #要监控的服务name
turbine.app-config=web-wap turbine.cluster-name-expression=new String("default")
management.endpoint.health.show-details=always
management.health.redis.enabled=false

  

4.启动 查看面板

最新文章

  1. Nagios学习笔记四:基于NRPE监控远程Linux主机
  2. 最近的shell脚本(updating)
  3. iOS开发:使用Block在两个界面之间传值(Block高级用法:Block传值)
  4. hadoop-2.6.0为分布式安装
  5. Global.asax使用1
  6. Scala基础入门-代码碎片
  7. JSP的学习(3)——语法知识二之page指令
  8. 用jQuery的ajax的功能实现输入自动提示的功能
  9. DevExpress 学习使用之 PrintSystem
  10. 【Sort】HeapSort
  11. 自然语言处理高手_相关资源_开源项目(比如:分词,word2vec等)
  12. JS的作用域浅谈
  13. HTML5-移动开发常用技巧与弹性布局的使用
  14. Go学习——new()和 make()的区别详解(转载)
  15. python使用魔法函数创建可切片类型
  16. 锐捷交换机配置DHCP SERVER给固定的MAC地址分配静态IP
  17. [转帖]NUMA架构的CPU -- 你真的用好了么?
  18. Http协议的理解
  19. 安装SourceTree遇到的一个个坑
  20. zabbix切换中文,监控图下方显示乱码,监控图X轴不显示时间问题解决(适用于所有版本)

热门文章

  1. Java 学习(7):java 日期时间 &amp; 正则表达式
  2. spring boot 中访问 REST 接口
  3. 无管理员帐号的WIN7,如果使用自己的JDK版本?
  4. 2.6-NAT
  5. NGINX之——配置HTTPS加密反向代理訪问–自签CA
  6. DirectX11 学习笔记6 - 使用D3DXMATH数学库的一个样例
  7. Python字符串转为字典方法大全
  8. 模拟IC
  9. Java 错误:找不到或无法加载主类(源文件中含有包名 package)
  10. 杂项-Java:标签库