日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring cloud构建互联网分布式微服务云平台-断路器聚合监控(Hystrix Turbine)

發布時間:2024/4/17 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring cloud构建互联网分布式微服务云平台-断路器聚合监控(Hystrix Turbine) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、Hystrix Turbine簡介

看單個的Hystrix Dashboard的數據并沒有什么多大的價值,要想看這個系統的Hystrix Dashboard數據就需要用到Hystrix Turbine。Hystrix Turbine將每個服務Hystrix Dashboard數據進行了整合。Hystrix Turbine的使用非常簡單,只需要引入相應的依賴和加上注解和配置就可以了。愿意了解源碼的朋友直接求求交流分享技術 一七九一七四三三八零

二、準備工作

本文使用的工程為上一篇文章的工程,在此基礎上進行改造。因為我們需要多個服務的Dashboard,所以需要再建一個服務,取名為service-lucy,它的基本配置同service-hi,具體見源碼,在這里就不詳細說明。

三、創建service-turbine

引入相應的依賴:

<dependencies><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-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-turbine</artifactId></dependency></dependencies>復制代碼

在其入口類ServiceTurbineApplication加上注解@EnableTurbine,開啟turbine,@EnableTurbine注解包含了@EnableDiscoveryClient注解,即開啟了注冊服務。

@SpringBootApplication @EnableEurekaClient @EnableDiscoveryClient @RestController @EnableHystrix @EnableHystrixDashboard @EnableCircuitBreaker @EnableTurbine public class ServiceTurbineApplication {/*** http://localhost:8764/turbine.stream*/public static void main(String[] args) {SpringApplication.run( ServiceTurbineApplication.class, args );} }復制代碼

配置文件application.yml:

spring:application.name: service-turbine server:port: 8769 security.basic.enabled: false turbine:aggregator:clusterConfig: default # 指定聚合哪些集群,多個使用","分割,默認為default??墒褂胔ttp://.../turbine.stream?cluster={clusterConfig之一}訪問appConfig: service-hi,service-la ### 配置Eureka中的serviceId列表,表明監控哪些服務clusterNameExpression: new String("default")# 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 eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/復制代碼

配置文件注解寫的很清楚。

Turbine演示

依次開啟server、service-hi、service-la、service-turbine工程。 打開瀏覽器輸入:http://localhost:8769/turbine.stream,

依次請求:

http://localhost:8762/hi?name=whhttp://localhost:8763/hi?name=wh 復制代碼

打開:http://localhost:8763/hystrix,輸入監控流http://localhost:8769/turbine.stream

可以看到這個頁面聚合了2個service的hystrix dashbord數據。

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的spring cloud构建互联网分布式微服务云平台-断路器聚合监控(Hystrix Turbine)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。