turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过 
turbine来监控集群下hystrix的metrics情况,通过eureka来发现hystrix服务。

1.断路器1

入口类

@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public class HystrixController {
public static void main(String[] args) {
SpringApplication.run(HystrixController.class, args);
}
}

service

@Service
public class HystrixService {
@HystrixCommand(fallbackMethod="fail")
public String reqmap(String param){
if(param.equals("wangjing")){
throw new RuntimeException();
}
return param+"--hystrix";
}
public String fail(String param){
return "runtimeException";
}
}

控制层

@RestController
@RequestMapping(value="/reqmap",produces={"application/json;charaset=utf-8"},method=RequestMethod.GET)
public class HystrixReqMap {
@Autowired
HystrixService hystrixService;
@RequestMapping("")
public String reqmap(String param){
return hystrixService.reqmap(param);
}
}

application.properties

spring.application.name=cloud-hystrix-one
server.port=8111
eureka.client.healthcheck.enabled=true
eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.lease-expiration-duration-in-seconds=10
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/,http://localhost:8762/eureka/
eureka.instance.hostname=windows1  #使用turbine进行本地测试时,可能会出现只展示一个仪表盘,是因为多个服务同时注册eureka(默认是以主机名注册),主机名全为localhost,所以要设置注册eureka的主机名。在hosts里记得配置。

2.断路器2

其它都一致

application.properties

spring.application.name=cloud-hystrix-two
server.port=8222
eureka.client.healthcheck.enabled=true
eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.lease-expiration-duration-in-seconds=10
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/,http://localhost:8762/eureka/
eureka.instance.hostname=windows2

3.turbine服务

添加依赖 <dependency>

		<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
application.properties中

spring.application.name=cloud-turbine
server.port=8999
eureka.client.healthcheck.enabled=true
eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.lease-expiration-duration-in-seconds=10
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/,http://localhost:8762/eureka/
turbine.appConfig=feign-client,loadbalance
turbine.aggregator.clusterConfig=default
turbine.clusterNameExpression=new String("default")

  • turbine.appConfig :配置Eureka中的serviceId列表,表明监控哪些服务
  • turbine.aggregator.clusterConfig :指定聚合哪些集群,多个使用”,”分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问
  • turbine.clusterNameExpression : 1. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称;2. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default;3. 当clusterNameExpression: metadata[‘cluster’]时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC

启动类

@SpringBootApplication
@EnableDiscoveryClient
@EnableTurbine
@EnableHystrixDashboard
public class CloudFurbineController {
public static void main(String[] args) {
SpringApplication.run(CloudFurbineController.class, args);
}
}

http://localhost:8999/hystrix返回酷酷的小熊界面,输入: http://localhost:8999/turbine.stream,然后点击 Monitor Stream ,可以看到出现了俩个监控列表

cloud turbine的更多相关文章

  1. 微服务架构之spring cloud turbine

    在前面介绍了spring cloud hystrix及其hystrix dashboard,但都是对单个项目的监控,对于一个为项目而言,必定有很多微服务,一个一个去看非常的不方便,如果有一个能集中熔断 ...

  2. Spring Cloud Turbine微服务集群实时监控

    本文代码下载地址: https://gitlab.com/mySpringCloud/turbine SpringBoot版本:1.5.9.RELEASE (稳定版) SpringCloud版本:Ed ...

  3. Spring Cloud Turbine 知识点

    Turbine 默认使用 Eureka 作为注册中心:如果使用 Consul 作为注册中心,需要排除掉 Eureka:pom.xml 如下: <dependency> <groupI ...

  4. spring cloud turbine 监控不到其它机器上的hystrix.stream 的解决方法 指定监控ip

    turbine多台机器熔断聚合的时候  turbine控制台一直寻找的是localhost下的监控熔断数据. c.n.t.monitor.instance.InstanceMonitor   : Ur ...

  5. Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十):服务熔断(Hystrix、Turbine)

    在线演示 演示地址:http://139.196.87.48:9002/kitty 用户名:admin 密码:admin 雪崩效应 在微服务架构中,由于服务众多,通常会涉及多个服务层级的调用,而一旦基 ...

  6. Spring Boot + Spring Cloud 构建微服务系统(六):熔断监控集群(Turbine)

    Spring Cloud Turbine 上一章我们集成了Hystrix Dashboard,使用Hystrix Dashboard可以看到单个应用内的服务信息,显然这是不够的,我们还需要一个工具能让 ...

  7. Spring Cloud(六):Hystrix 监控数据聚合 Turbine【Finchley 版】

    Spring Cloud(六):Hystrix 监控数据聚合 Turbine[Finchley 版]  发表于 2018-04-17 |  更新于 2018-05-07 |  上一篇我们介绍了使用 H ...

  8. 推荐一个spring cloud 学习路线,绝对合理化

    最近没有时间所有没用给大家更新spring cloud 系列学习,在这先给大家奉献上我学习spring cloud 的路线 当然第一步先学习springboot然后: spring cloud eur ...

  9. 熔断监控集群(Turbine)

    Spring Cloud Turbine 上一章我们集成了Hystrix Dashboard,使用Hystrix Dashboard可以看到单个应用内的服务信息,显然这是不够的,我们还需要一个工具能让 ...

随机推荐

  1. SVN版本控制详解

    1 版本控制 1.1 如果没有版本控制? Team开发必备. 一个人开发(必备). 版本控制:控制(代码)版本. 论文:版本控制? 毕业论文-4-22.doc 毕业论文-5-01.doc 毕业论文-f ...

  2. dataguard类型转换与模式转化

    修改数据保护模式步骤 前提:是否满足转换模式的配置要求 最大保护(Maximum Protection):Standby Database 必须配置Standby Redo Log,Primary D ...

  3. poj1734Sightseeing trip——无向图求最小环

    题目:http://poj.org/problem?id=1734 无向图求最小环,用floyd: 在每个k点更新f[i][j]之前,以k点作为直接连到i,j组成一个环的点,这样找一下最小环: 注意必 ...

  4. 【何镇汐】-Web UI Util 框架

    http://www.cnblogs.com/xiadao521/p/4518516.html

  5. 3、scala数组

    一.Array .Array Buffer 1.Array 在Scala中,Array代表的含义与Java中类似,也是长度不可改变的数组. 此外,由于Scala与Java都是运行在JVM中,双方可以互 ...

  6. 【机器学习】迭代决策树GBRT(渐进梯度回归树)

    一.决策树模型组合 单决策树C4.5由于功能太简单,并且非常容易出现过拟合的现象,于是引申出了许多变种决策树,就是将单决策树进行模型组合,形成多决策树,比较典型的就是迭代决策树GBRT和随机森林RF. ...

  7. 2-1 本章作业&2-2 开发系统与工具选择

    2-1 2-2 推荐使用Android Studio开发Flutter

  8. ACM-ICPC2018北京网络赛 80 Days(双端队列+尺取)

    题目4 : 80 Days 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 80 Days is an interesting game based on Jules Ve ...

  9. AutoHotkey常用配置

    ; 开发常用 ^e:: run D:\soft\java\MyEclipse for Spring 2014\myeclipseforspring.exe return ^d:: run D:\sof ...

  10. js选中select

    function selected(id, val) { $('#' + id + ' option[value="' + val + '"]').attr('selected', ...