码迷,mamicode.com
首页 > 其他好文 > 详细

服务容错保护断路器Hystrix之四:turbine集群监控

时间:2017-09-15 13:57:45      阅读:1241      评论:0      收藏:0      [点我收藏+]

标签:ges   pack   增加   client   结果   static   enc   div   指定   

turbine 英[?t?:ba?n] n. 汽轮机; 涡轮机; 透平机;

本文通过引入Turbine来聚合ribbon-consumer服务的监控信息,并输出给hystrix dashboard来进行展示。

先上部署拓扑图:

技术分享

构建turbine项目:

pom文件:

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

    <groupId>com.dxz.turbine</groupId>
    <artifactId>turbine</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>hystrix-dashboard</name>
    <description>dashboard project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>   <!--配合spring cloud版本 -->
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <!--设置字符编码及java版本 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!--增加turbine的依赖 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-turbine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--用于测试的,本例可省略 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!--依赖管理,用于管理spring-cloud的依赖 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-parent</artifactId>
                <version>Brixton.SR3</version>   <!--官网为Angel.SR4版本,但是我使用的时候总是报错 -->
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <!--使用该插件打包 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

启动类TurbineApplication

package com.dxz.turbine;

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

@EnableTurbine
@EnableDiscoveryClient
@SpringBootApplication
public class TurbineApplication {

    public static void main(String[] args) {
        SpringApplication.run(TurbineApplication.class, args);
    }
}

 

 

配置信息

spring.application.name=turbine
server.port=2260
management.port=8990

eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/

turbine.app-config=ribbon-consumer
turbine.cluster-name-expression="default"
turbine.combine-host-port=true

 


其中
turbine.app-config:指定被收集监控信息的服务名
turbine.cluster-name-expression:如果集群有多个时,用来区分集群
turbine.combine-host-port:可以让同一台主机上的服务通过主机名和端口号组合来进行区分。

 

启动turbine项目,

http://127.0.0.1:2260/turbine.stream

将http://127.0.0.1:2260/turbine.stream填入dashboard里,

技术分享

结果:

技术分享

 与消息代理结合

技术分享

 

 详细见《spring cloud微服务实战》

服务容错保护断路器Hystrix之四:turbine集群监控

标签:ges   pack   增加   client   结果   static   enc   div   指定   

原文地址:http://www.cnblogs.com/duanxz/p/7525753.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!