Springcloud的turbine配置使用

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

<?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>java

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

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

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

    <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>app


</project>
 dom

二、在application.yml配置maven

---  
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']

三、启动程序配置spring-boot

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);
    }
}
四、在被监控的服务application.yml中的euraka服务器配置为,红色为增添的内容

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

五、打开地址输入

 

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

相关文章
相关标签/搜索