使用Turbine监控多个微服务

一 为了让Turbine监控2个以上的微服务,先建一个项目microservice-consumer-movie-feign-hystrix-fallback-stream,确保该项目的application.yml配置如下
server:
  port: 8020
spring:
  application:
    name: microservice-consumer-movie-feign-hystrix-fallback-stream
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    prefer-ip-address: true
二 创建一个Maven项目,项目名为microservice-hystrix-turbine,并为项目添加以下依赖
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-turbine</artifactId>
    </dependency>
三 在启动类上添加注解@EnableTurbine
package com.itmuch.cloud.study;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.turbine.EnableTurbine;

@SpringBootApplication
@EnableTurbine
public class TurbineApplication {
  public static void main(String[] args) {
    SpringApplication.run(TurbineApplication.class, args);
  }
}
四 编写配置文件application.yml
server:
  port: 8031
spring:
  application:
    name: microservice-hystrix-turbine
eureka:
  client:
    service-url:
      defaultZone:http://localhost:8761/eureka/
  instance:
    prefer-ip-address: true
turbine:
  appConfig: microservice-consumer-movie,microservice-consumer-movie-feign-hystrix-fallback-stream
  clusterNameExpression: "'default'"
使用以上配置,Turbine会在Eureka Server中找到microservice-consumer-movie和microservice-consumer-movie-feign-hystrix-fallback-stream这两个微服务,并聚合这两个微服务的监控数据
五 测试
1 启动eureka
2 启动user微服务
3 启动项目microservice-consumer-movie-ribbon-hystrix
4 启动项目microservice-consumer-movie-feign-hystrix-fallback-stream
5 启动项目microservice-hystrix-turbine
6 启动项目microservice-hystrix-dashboard
7 观察eureka
8 访问 http://localhost:8010/user/1,让microservice-consumer-movie-ribbon-hystrix微服务产生监控数据
9 访问 http://localhost:8020/user/1,让microservice-consumer-movie-feign-hystrix-fallback-stream微服务产生监控数据
10 打开 http://localhost:8030/hystrix,进入Hystrix Dashboard首页,在URL地址栏输入 http://localhost:8031/turbine.stream,然后点击监控按钮,得到如下界面:

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值