您的位置:首页 > 编程语言 > Java开发

Springcloud的turbine配置使用

2017-03-07 20:59 253 查看
摘要: 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>
&l
3ff0
t;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、打开地址输入




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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Hystrix
相关文章推荐