Spring Cloud 添加Dashboard断路监控

spring boot版本:2.1.10.RELEASE
适用于spring boot 2.x

1、添加相关依赖
<!--spring-boot-starter-actuator 可以得到SpringBoot项目的各种信息-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--spring boot 2.0以后依赖改为以下-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
2、配置启动类
package com.ebook.consumer;

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

/**
 * @author:JZ
 * @date:2020/1/11
 */

@EnableCircuitBreaker  //开启服务降级 断路器
@EnableEurekaClient
@SpringBootApplication
@EnableHystrixDashboard   //开启HystrixDashboard
public class ThreadPoolApplication {

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

}

3、添加配置文件

management.endpoints.web.exposure.include=hystrix.stream
management.endpoints.web.base-path=/

SpringBoot2.x以上必须指定,指定hystrixDashboard的访问路径,否则访问http://127.0.0.1:8021/hystrix.stream 时报前端页面会报如下错误:
在这里插入图片描述

4、查看页面

以下url中IP和端口请根据自己的情况自行修改。

访问http://127.0.0.1:8021/hystrix.stream

若未请求过接口页面如下:
在这里插入图片描述

请求接口后:
在这里插入图片描述

访问http://127.0.0.1:8021/hystrix

在这里插入图片描述
其中的http://127.0.0.1:8021/hystrix.stream就是上边的url,也就是需要监听的服务。
Delay:轮询监控的时间间隔,默认为2000。
Title:标题,随意起。

点击 monitor stream 按钮
在这里插入图片描述
解释:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值