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

本文介绍如何使用Turbine改造Hystrix Dashbord项目,实现一个监控页面对多个消费者的集群监控。通过增加Turbine依赖、配置yml文件、修改主启动类,最终在本地测试成功,简化了监控操作。

1. 现状

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

2. 改造Dashbord项目

2.1 pom依赖

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

<dependencies>
    <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>
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页面表示成功
集群监控
在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值