使用Turbine對集群進行監控
阿新 • • 發佈:2018-12-13
string 127.0.0.1 cati info 情況 tar artifact 發送 onf
為什麽要使用Turbine
T
urbine
是聚合服務器發送事件流數據的一個工具,hystrix的監控中,只能監控單個節點,實際生產中都為集群,因此可以通過turbine來監控集群下hystrix的metrics情況,通過eureka來發現hystrix服務。
如何使用Turbine
前提
新建一個springboot項目springboot-turbine
引入Turbine
pom.xml:
<dependencies> <!-- 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> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies>
修改啟動類
在啟動類上加上註解@EnableTurbine
配置yml配置文件
server: port: 8010 spring: application: name: xing-turbine #指定服務名 turbine: aggregator: clusterConfig: default # 指定聚合哪些集群,多個使用","分割,默認為default。 appConfig: XING-MOVIE # 配置Eureka中的serviceId列表,表明監控哪些服務 clusterNameExpression:new String("default") eureka: client: registerWithEureka: true #是否將自己註冊到Eureka服務中,默認為true fetchRegistry: true #是否從Eureka中獲取註冊信息,默認為true serviceUrl: #Eureka客戶端與Eureka服務端進行交互的地址 defaultZone: http://xing-eurekaServer:8090/eureka/ eurekaServerConnectTimeoutSeconds: 60 eurekaServerReadTimeoutSeconds:60 instance: prefer-ip-address: true #將自己的ip地址註冊到Eureka服務中 ip-address: 127.0.0.1 instance-id: xing-turbine:8010 #指定實例id lease-expiration-duration-in-seconds: 30 #續約更新時間間隔(默認30秒) lease-renewal-interval-in-seconds: 10 # 續約到期時間(默認90秒) leaseRenewalIntervalInSeconds: 10 #心跳時間 hostname: xing-turbine
查看Turbine
啟動項目,訪問http://127.0.0.7:xxxx/turbine.stream 會看到如下圖類似的界面
接著訪問http://127.0.0.1:xxxx/hystrix 出現Hystrix Dashboard的界面
之後會看到這個界面
使用Turbine對集群進行監控