Hystrix的监控及可视化面板

本文介绍了如何使用Hystrix Dashboard进行微服务监控,包括设置数据可视化面板,使用Turbine聚合多个实例的监控数据,以及在无法直接网络通信时通过消息中间件RabbitMQ收集和展示Hystrix监控数据。
摘要由CSDN通过智能技术生成

Hystrix监控

Hystrix除了实现容错之外,还提供了近乎实时的监控。Hystrix Command和HystrixObservableCommand在执行时,会会生成执行结果和运行指标,比如每秒的请求数和成功数等,这些监控数据对于分析系统请求的调用情况很有用。

我们以之前项目介绍过的micro-service-consumer-ribbon-hystrix为例,因为之前的项目中已经包含了spring-boot-starter-actuator和spring-cloud-starter-hystrix,因此可以直接通过http://localhost:7908/hystrix.stream来访问,但是页面展示的并不直观。
Hystrix实现微服务的容错处理

那么为什么之前介绍的micro-service-consumer-movie-feign-hystrix-fallback-factory打开http://localhost:8028/hystrix.stream却是404呢?
因为在引入feign的时候带了hystrix,因此只需要再单独引入hystrix即可,同时还需要在启动类上加@EnableCircuitBreaker。

 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>

使用Hystrix Dashboard 数据可视化监控面板

创建micro-service-hystrix-dashboard项目,首先来看一下这个项目的pom文件,我们引入了spring-cloud-starter-hystrix-dashboard的依赖:

<?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>micro-service-hystrix-dashboard</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>com.fanfan.cloud</groupId>
        <artifactId>micro-service-spring-cloud-study</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
    </dependencies>

    <!-- 引入spring cloud的依赖 -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Edgware.SR6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <finalName>micro-service-hystrix-dashboard</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值