〖Spring Cloud〗Dashboard 流监控

本文介绍了如何在Spring Cloud项目中集成Hystrix Dashboard进行流监控。通过添加相关依赖,创建主启动类,并在服务提供者中配置Servlet,可以实现对服务的实时监控。访问特定URL即可查看监控页面,展示服务的运行状态和性能指标。
摘要由CSDN通过智能技术生成

Dashboard 流监控

相关视频教程(来自动力节点):https://www.bilibili.com/video/BV1nK4y1j7gL

相关资料下载:http://www.bjpowernode.com/?csdn

新建springcloud-consumer-hystrix-dashboard模块

添加依赖

<!--Hystrix依赖-->

<dependency>

    <groupId>org.springframework.cloud</groupId>

    <artifactId>spring-cloud-starter-hystrix</artifactId>

    <version>1.4.6.RELEASE</version>

</dependency>

<!--dashboard依赖-->

<dependency>

    <groupId>org.springframework.cloud</groupId>

    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>

    <version>1.4.6.RELEASE</version>

</dependency>

<!--Ribbon-->

<dependency>

    <groupId>org.springframework.cloud</groupId>

    <artifactId>spring-cloud-starter-ribbon</artifactId>

    <version>1.4.6.RELEASE</version>

</dependency>

<!--Eureka-->

<dependency>

    <groupId>org.springframework.cloud</groupId>

    <artifactId>spring-cloud-starter-eureka</artifactId>

    <version>1.4.6.RELEASE</version>

</dependency>

<!--实体类+web-->

<dependency>

    <groupId>com.haust</groupId>

    <artifactId>springcloud-api</artifactId>

    <version>1.0-SNAPSHOT</version>

</dependency>

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-web</artifactId>

</dependency>

<!--热部署-->

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-devtools</artifactId>

</dependency>

主启动类

@SpringBootApplication

// 开启Dashboard

@EnableHystrixDashboard

public class DeptConsumerDashboard_9001 {

    public static void main(String[] args) {

        SpringApplication.run(DeptConsumerDashboard_9001.class,args);

    }

}



给springcloud-provider-dept-hystrix-8001模块下的主启动类添加如下代码,添加监控

@SpringBootApplication

@EnableEurekaClient //EnableEurekaClient 客户端的启动类,在服务启动后自动向注册中心注册服务

public class DeptProvider_8001 {

    public static void main(String[] args) {

        SpringApplication.run(DeptProvider_8001.class,args);

    }



    //增加一个 Servlet

    @Bean

    public ServletRegistrationBean hystrixMetricsStreamServlet(){

        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());

        //访问该页面就是监控页面

        registrationBean.addUrlMappings("/actuator/hystrix.stream");

       

        return registrationBean;

    }

}

访问:http://localhost:9001/hystrix

进入监控页面:

效果如下图:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值