本文共 2416 字,大约阅读时间需要 8 分钟。
Turbine真正做的,就是将每一个(指定)服务的Hystrix/stream中的状态信息取出,并集中处理(计算与展示),应该说,它是具有自己独立的调度的,服务(实例)发现,服务连接,数据聚合,数据输出,共四个过程。
如上图: Turbine首先通过InstanceDiscovery
模块获取所有的实例信息(定期更新获取),ConnectionManager
负责连接到实例,连接上实例后,便会有源源不断的数据流发送给聚合器Aggregator
之后,再传送给需要的地方。
在使用HystrixDashboard组件监控服务的熔断器状况时,每个服务都有一个HystrixDashboard主页,当服务数量很多时,监控非常不方便。为了同时监控多个服务的熔断器的状况,Netflix 开源了Hystrix 的另一个组件Turbine。Turbine 用于聚合多个Hystrix Dashboard,将多个Hystrix Dashboard组件的数据放在一个页面 上展示,进行集中监控。
依赖:
org.springframework.cloud spring-cloud-starter-turbine org.springframework.boot spring-boot-starter-actuator
配置:
spring: application: name: service-turbineserver: port: 8769turbine: aggregator: clusterConfig: default #指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={ clusterConfig}访问 app-config: eureka-ribbon-client,eureka-feign-client #配置Eureka中的serveceId列表,表明监控哪些服务 cluster-name-expression: new String("default") # 1. ClusterNameExpression:指定集群名称,默认表达式appName;此时trubine.aggregatro.clusterConfig需要配置想要监控的应用名称 # 2. 当ClusterNameExpression:default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default # 3. 当ClusterNameExpression:metadata['cluster']时,假设想要监控的应用配置了 # eureka.instance.metadata-map.cluster:ABC,则需要配置,同时turbine.aggregator.clusterConfig:ABCeureka: client: service-url: defaultZone: http://localhost:8761/eureka/
示例:
turbine: aggregator: clusterConfig:CLOUD_SIMPLE_SERVICE appConfig:cloud-simple-service clusterNameExpression:metadata['cluster']在hystrix dashboard的监控url中就应该输入:http://localhost:port/turbine.stream?cluster=CLOUD-SIMPLE-SERVICEcluster对应clusterConfig中的名称
开启turbine
@SpringBootApplication@EnableTurbine//开启trubinepublic class EurekaMonitorClientApplication { public static void main(String[] args) { SpringApplication.run(EurekaMonitorClientApplication.class, args); }}
启动工程eureka-server、eureka-client、 eureka-ribbon-client 和eureka-monitor -client。
在浏览器上访问http://localhost:8764hi?name-forezp和ht:/calhost:8765/hi?name=forezpo
在界面上依次输入监控流的Url地址htp://localhost:8769/turbine.stream
、监控时间间隔2000毫秒和title,单击“monitor”,可以看到如图
这个页面聚合了eureka-ribbon-client和eureka-feign-client的Hystrix Dashboard数据。
转载地址:http://gapqb.baihongyu.com/