0045-一个Dashbord页面监控多个消费者

文章目录

      • 1. 现状
      • 2. 改造Dashbord项目
        • 2.1 pom依赖
        • 2.2 yml配置
        • 2.3 主启动类
        • 2.4 测试

1. 现状

目前Hystrix项目可以监控消费者,但是每一个消费者就需要启动一个监控页面,很不方便,可以通过Turbine实现一个监控页面,监控多个消费者

2. 改造Dashbord项目

2.1 pom依赖

增加turbine的依赖,其它和单机dashbord一致


    
        org.springframework.boot
        spring-boot-starter-actuator
    
    
        org.springframework.cloud
        spring-cloud-starter-netflix-hystrix
    
    
        org.springframework.cloud
        spring-cloud-starter-netflix-hystrix-dashboard
    
    
        org.springframework.cloud
        spring-cloud-starter-netflix-turbine
    

2.2 yml配置

监控集群需要从Eureka-Server获取消费者服务

server:
  port: 10001

eureka:
  client:
    serviceUrl:
      defaultZone: http://eureka-server-7001:7001/eureka/,http://eureka-server-7002:7002/eureka/,http://eureka-server-7003:7003/eureka/
  instance:
    instance-id: eureka-consumer-hystrix-dashbord-10001 # 服务名称
    prefer-ip-address: true # 显示ip地址

info: # 点击注册列表未服务出现的信息
  app.name: springcloud
  company.name: www.honor.com
  build.artifactId: @project.artifactId@
  build.version: @project.version@

spring:
  application:
    name: eureka-consumer-hystrix-dashbord

turbine:
  combine-host-port: true
  app-config: EUREKA-CONSUMER #需要监控的集群名称
  aggregator:
    cluster-config: default
  cluster-name-expression: new String("default")

2.3 主启动类

@SpringBootApplication
@EnableHystrixDashboard
@EnableTurbine
public class EurekaConsumeHystrixDashbord10001 {
    public static void main(String[] args) {
        SpringApplication.run(EurekaConsumeHystrixDashbord10001.class, args);
    }
}

2.4 测试

浏览器输入http://localhost:10001/turbine.stream可以看到ping页面表示成功
集群监控
0045-一个Dashbord页面监控多个消费者_第1张图片

0045-一个Dashbord页面监控多个消费者_第2张图片

你可能感兴趣的:(#,Spring,Cloud)