Springcloud的turbine配置使用

turbine是聚合服务器发送事件流数据的一个工具,hystrix的监控中,只能监控单个节点,实际生产中都为集群,因此可以通过 turbine来监控集群下hystrix的metrics情况,通过eureka来发现hystrix服务。
1、jar包pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>love-life-turbine</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>love-life-turbine</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.3.5.RELEASE</version>
    </parent>

    <properties>
         <start-class>com.love.life.turbine.boot.TurbineApplication</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>
     <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- eureka依赖 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
    <!-- hystrix依赖 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
    </dependency>
     <!-- turnbine依赖 -->
     <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-turbine</artifactId>
     </dependency>
     
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>
 

2、在application.yml配置

---  
spring:
  rabbitmq:
    host: localhost
    port: 5672
    username: zhb
    password: zhb
    virtual-host: cloud-zhb
eureka:
  instance:
    preferIpAddress: true
    statusPageUrlPath: /info.html
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
turbine:
  appConfig: love-origami-domain,cloud-cust-domain,love-life-app
  aggregator:
    clusterConfig: MAIN
  clusterNameExpression: metadata['cluster']

3、启动程序配置

package com.love.life.turbine.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;
import org.springframework.context.annotation.Bean;

/**
 * 项目的启动类,指定扫描的包路径
 * @author itw_huomb
 */
@EnableTurbine
@EnableHystrixDashboard
@SpringBootApplication
@EnableEurekaClient
public class TurbineApplication
{

    public static void main(String[] args)
    {
        SpringApplication.run(TurbineApplication.class, args);
    }
}
4、在被监控的服务application.yml中的euraka服务器配置为,红色为增添的内容

eureka:
  instance:
    preferIpAddress: true
    statusPageUrlPath: /info.html
    metadata-map:
      cluster: MAIN

5、打开地址输入

190554_ZbHS_2404345.png

 

190700_geT1_2404345.png

7、在各客户端应用的服务端的断路器配置处

 

转载于:https://my.oschina.net/Seaside20151225/blog/745281

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值