SpringCloud极简入门>断路器监控#hystrix dashboard

本文介绍了如何通过Hystrix Dashboard监控微服务的调用情况,包括配置Hystrix Dashboard模块,设置相关依赖和YAML配置,以及在服务不可达时的监控效果。当需要监控多个微服务时,可以通过Turbine组件实现。
摘要由CSDN通过智能技术生成

简介

hystrix dashboard可以监控微服务间调用情况,当有服务不可达时可以在控制台及时发现;但是只能监控一个微服务,若是要监控多个微服务,可以使用turbine组件;

前置内容:

实战

1、创建《hystrix-dashboard》模块

1.1、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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>cc.catface</groupId>
        <artifactId>simple-eureka</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>hystrix-dashboard</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>server-account</name>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
        </dependency>
    </dependencies>
</project>

1.2、yml

server:
  port: 8060

spring:
  application:
    name: hystrix-dashboard

eureka:
  client:
    service-url:
      defaultZone: http://localhost:7000/eureka/

1.3、application

1、《server-account》的application声明注解@EnableCircuitBreaker,即将信息分享给监控中心hystrix dashboard;

2、《hystrix-dashboard》的application声明注解@EnableHystrixDashboard,即开启hystrix dashboard监控器;

2、查看效果

2.1、发起请求

请求http://localhost:7003/testFeign;

2.2、打开控制台观察

打开http://localhost:8060/hystrix,输入http://localhost:7003/actuator/hystrix.stream,点击Monitor Stream;
在这里插入图片描述
在这里插入图片描述

2.3、不停请求观察控制台

29是请求次数,0.0%表示《server-account》服务正常;
在这里插入图片描述

2.4、关闭《server-account》再不停请求观察控制台

100.0%表示《server-account》已不可达;
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值