前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >springcloud turbine与hystrix dashboard集成使用

springcloud turbine与hystrix dashboard集成使用

作者头像
lyb-geek
发布2018-12-12 16:14:36
1.9K0
发布2018-12-12 16:14:36
举报
文章被收录于专栏:Linyb极客之路Linyb极客之路

什么是turbine

Turbine是聚合服务器发送事件流数据的一个工具,用来监控集群下hystrix的metrics情况。Turbine通过注册中心获取对应集群下的所有微服务实例,然后依次访问每个实例的/hystrix.stream,并收集和聚合所有节点健康信息

turbine的作用

汇总系统内多个服务的数据并显示到Hystrix Dashboard 上

turbine的搭建

1、引入maven依赖

代码语言:javascript
复制
<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-starter-turbine</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-starter-eureka</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-actuator</artifactId> 
</dependency>

新版的依赖为

代码语言:javascript
复制
<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-starter-netflix-turbine</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-actuator</artifactId> 
</dependency>

2、创建启动类

代码语言:javascript
复制
@SpringBootApplication
@EnableDiscoveryClient
@EnableTurbine
public class TurbineServer {

    private static Logger logger = LoggerFactory.getLogger(TurbineServer .class);

    public static void main(String[] args) {


        SpringApplication.run(TurbineServer .class, args);
    }
}

注:如果是使用新版的eureka客户端依赖,则无需加上@EnableDiscoveryClient注解

3、配置

代码语言:javascript
复制
server:
  port: 7400
spring:
  application: 
    name: ${deploy.servicename}
turbine:
  aggregator:
    clusterConfig: muse,oxford 

  appConfig: aaabbb
  clusterNameExpression: metadata['cluster']
  instanceUrlSuffix:
     oxford: /Oxford/hystrix.stream
eureka:
  instance:
    ipAddress: ${eurekaInstanceIpAddress}
    preferIpAddress: true
    name: ${deploy.servicename}
    metadataMap:
      zone: ${eurekaZone}
    instanceId: ${deploy.servicename}_${spring.cloud.client.ipAddress}
  client:
    serviceUrl:
      defaultZone: ${eurekaClientServiceUrlDefaultZone}
    healthcheck:
       enabled: true

4、配置文件turbine参数介绍

1、turbine.aggregator.clusterConfig # 指定聚合哪些集群,多个使用","分割,默认为default。可使用http://.../turbine.stream?cluster={clusterConfig之一}访问 2、turbine.appConfig # 配置Eureka中的serviceId列表,表明监控哪些服务 3、turbine.clusterNameExpression a. clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称 b. 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default c. 当clusterNameExpression: metadata['cluster']时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC。即:从客户端的metadata-map的元数据中取key=cluster的值,如果跟上面配置的clusterConfig中的一致才可以访问 4、turbine.instanceUrlSuffix.oxford #由于某些项目配置了context-path,而默认的turbine访问的hystrix.stream是/hystrix.stream,这会导致turbine不能采集到配置context-path的项目信息。因此需要配置turbine.instanceUrlSuffix.[clusterName]=/context-path/hystrix.stream

5、 当clusterNameExpression: metadata['cluster'],则客户端需要添加行如

代码语言:javascript
复制
eureka:
  instance:
    metadataMap:
      cluster: muse

6、 启动hystrix dashborad查看turbine汇集的系统信息

hystrix dashborad界面输入形如:

http://turbine-hostname:port/turbine.stream?cluster=[clusterName]

小结

以上是turbine搭建的简单入门,在实际开发中,turbine通常聚合网关服务就可以,因为基本上微服务都是通过网关访问,当然要具体根据实际情况分析

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-11-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Linyb极客之路 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 什么是turbine
  • turbine的作用
  • turbine的搭建
  • 小结
相关产品与服务
微服务引擎 TSE
微服务引擎(Tencent Cloud Service Engine)提供开箱即用的云上全场景微服务解决方案。支持开源增强的云原生注册配置中心(Zookeeper、Nacos 和 Apollo),北极星网格(腾讯自研并开源的 PolarisMesh)、云原生 API 网关(Kong)以及微服务应用托管的弹性微服务平台。微服务引擎完全兼容开源版本的使用方式,在功能、可用性和可运维性等多个方面进行增强。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档