cloud turbine

news/2024/7/8 0:48:24

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 ,可以看到出现了俩个监控列表

 

转载于:https://www.cnblogs.com/wangjing666/p/7055541.html


http://lihuaxi.xjx100.cn/news/240528.html

相关文章

ux体验网站 英国_?? 用户体验(UX)资源和工具的完整列表??

ux体验网站 英国by Jason Hreha杰森赫雷哈(Jason Hreha) ?? 用户体验(UX)资源和工具的完整列表?? (?? The Complete List of User Experience (UX) Resources & Tools ??) 超过100个链接&#xff0c;可以链接到最好的书籍&#xff0c;课程&#xff0c;新闻通讯和工…

大众点评数据平台架构变迁

2019独角兽企业重金招聘Python工程师标准>>> 最近和其他公司的同学对数据平台的发展题做了一些沟通&#xff0c;发现各自遇到的问题都类似&#xff0c;架构的变迁也有一定的相似性。 以下从数据&架构&应用的角度对2012.07-2014.12期间大众点评数据平台的架构…

设计模式(2)工厂方法模式(Factory Method)

设计模式&#xff08;0&#xff09;简单工厂模式 设计模式&#xff08;1&#xff09;单例模式&#xff08;Singleton&#xff09; 源码地址 0 工厂方法模式简介 0.0 工厂方法模式定义 工厂方法模式是在简单工厂模式基础上&#xff0c;为解决更复杂的对象创建问题而衍生进化出来…

百练,4103,踩方格

百练&#xff0c;4103&#xff0c;踩方格 普通做法&#xff1a;&#xff08;也可以找规律&#xff09; #include #include//要调用memset函数&#xff0c;头文件 using namespace std; int visited[50][50];//开辟50*50的方格 int num0;//num为方案数 void ways(int i,int j,i…

模糊推理 控制 易于实现_代码“易于推理”是什么意思?

模糊推理 控制 易于实现by Preethi Kasireddy通过Preethi Kasireddy 代码“易于推理”是什么意思&#xff1f; (What does it mean when code is “easy to reason about”?) You’ve probably heard the expression “easy to reason about” enough times to make your ear…

sendmail服务器配置过程中出现的一些错误和解决办法

sendmail服务器配置过程中出现的错误和解决办法 以前在做实验的过程中总结和写的一些教程的一些资料&#xff0c;一直没时间发布到博客上面&#xff0c;五一到了&#xff0c;终于有点时间发布啦&#xff01;关于Linux上面还会有RHCE系列的学习笔记发表 1、rpm包不能正常卸载&am…

RBAC新解 - 基于资源的权限管理

1、什么是角色 当说到程序的权限管理时&#xff0c;人们往往想到角色这一概念。角色是代表一系列可执行的操作或责任的实体&#xff0c;用于限定你在软件系统中能做什么、不能做什么。用户帐号往往与角色相关联&#xff0c;因此&#xff0c;一个用户在软件系统中能做什么取决于…

java配置

对于现在学习java的同学来说&#xff0c;还是安装12版本比较好&#xff0c;安装也比较&#xff08;是非常方便跟7比起来&#xff09;方便&#xff0c;。。。强烈建议