spring cloud dashboard的简单应用

一、简介   

Hystrix Dashboard是Hystrix熔断器的一个组件,它未用户提供了相对友好的图形化界面来监控接口访问数据。下面我们通过demo来学习。

二、通过demo学习

新建一个dashboard-service项目。

1、pom.xml依赖

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

 

2、application.properties配置

server.port=9095
spring.application.name=dashboard-service
hystrix.dashboard.proxy-stream-allow-list=*

3、项目代码

package com.example.dashboardservice9095;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

@EnableHystrixDashboard
@SpringBootApplication
public class DashboardService9095Application {
//    http://localhost:9095/hystrix
//    http://localhost:7070/actuator/hystrix.stream
    public static void main(String[] args) {
        SpringApplication.run(DashboardService9095Application.class, args);
    }

}

三、总结

   启动项目后,我们访问dashboard-service:http://localhost:9095/hystrix 打开Dashboard界面。

如果我们想监控A应用的接口熔断情况,我们需要在A应用中添加以下依赖:

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

并且需要我们在A应用的yml配置文件中新增以下配置:

management:
  endpoints:
    web:
      exposure:
        include: refresh,hystrix.stream #refresh打开actuator的配置文件刷新设置;hystrix.stream:打开hystrix状态信息获取

这样我们就可以监控A应用的请求情况了。假设A应用的服务地址是:http://localhost:7070/,我们可以访问:http://localhost:7070/actuator/hystrix.stream查看A应用中接口的熔断情况。或者我们可以通过hystrix-dashboard来监控:

简单讲解下dashboard的图形界面:
上面的“queryOrder”、“queryOrderTimeout”为监听熔断的接口;
下面灰色的圆圈代表是健康情况,如果是红色则代表不健康,形状越大流量越大
凸起来的灰色线,是请求的流量的变化情况
第一列 监控的是request请求
第一个绿色的数字,代表成功访问请求的数量,对应横向的绿色Success。98%是错误率。
第二个蓝色的数字,代表Short-Circuited
第三个青色的数字,代表错误请求的数量
第二列 针对的是response
第一个橙色的数字,代表超时访问的数量
第二个紫色的数字,代表拒绝访问的数量
第三个红色的数字,代表失败的服务数量
第三列 针对的是request/response 错误比例 或者成功比例
最重要的一个指标是参考 Circuit 代表熔断器的状态 close的关闭,open是打开

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值