turbine 集群聚合监控

hystrix + turbine 集群聚合监控

ystrix dashboard 一次只能监控一个服务实例,使用 turbine 可以汇集监控信息,将聚合后的信息提供给 hystrix dashboard 来集中展示和监控

使用步骤

前提

已经有了部分业务项目, 并使用feign进行了远程调用, 且业务项目绑定了注册中心

1. 新建项目导入依赖

创建springboot项目, 并导入: Turbine, Eureka Discovery Client

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>

2. 配置文件application.yml

spring:
  application:
    name: turbin
    
server:
  port: 5001
  
eureka:
  client:
    service-url:
      defaultZone: http://eureka1:2001/eureka, http://eureka2:2002/eureka
      
turbine:
  app-config: order-service
  cluster-name-expression: new String("default")

3. 主程序添加注解

添加 @EnableTurbine@EnableDiscoveryClient (高版本可省略此注解) 注解

@EnableTurbine
// @EnableDiscoveryClient 高版本springboot可省略
@SpringBootApplication
public class Sp10TurbineApplication {

	public static void main(String[] args) {
		SpringApplication.run(Sp10TurbineApplication.class, args);
	}

}

4. 访问测试

turbine 监控路径 http://localhost:5001/turbine.stream

我们使用仪表盘的时候, 只需要输入此路径即可

如果有相同的服务器进行了负载均衡, 再仪表盘面板可以看到属性 hosts = 2 或者更多(负载均衡服务)

posted @ 2020-08-31 19:38  zpk-aaron  阅读(226)  评论(0编辑  收藏  举报