spring-cloud服务监控

1.简单介绍

服务监控 hystrixDashboard
除了隔离依赖服务的调用以外,Hystrix还提供了准实时的调用监控(Hystrix Dashboard),Hystrix会
持续地记录所有通过Hystrix发起的请求的执行信息,并以统计报表和图形的形式展示给用户,包括每秒
执行多少请求,多少成功,多少失败等等。
Netflix通过hystrix-metrics-event-stream项目实现了对以上指标的监控,SpringCloud也提供了Hystrix
Dashboard的整合,对监控内容转化成可视化界面!

2.相关配置

新建工程springcloud-consumer-hystrix-dashboard-9001
Pom.xml
复制之前80项目的pom文件,新增以下依赖!

 
  1. <dependency>

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

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

  4. <version>1.4.7.RELEASE</version>

  5. </dependency>

  6. <dependency>

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

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

  9. <version>1.4.7.RELEASE</version>

  10. </dependency>

将端口号改为9001

修改主启动类:

 
  1. package com.csh.springcloud;

  2. import org.springframework.boot.SpringApplication;

  3. import org.springframework.boot.autoconfigure.SpringBootApplication;

  4. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

  5. import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

  6. import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;

  7. import org.springframework.cloud.openfeign.EnableFeignClients;

  8. import org.springframework.context.annotation.ComponentScan;

  9. @SpringBootApplication

  10. @EnableHystrixDashboard//新注解,开启功能

  11. public class Springcloudconsumer80feigndashboard {

  12. public static void main(String[] args) {

  13. SpringApplication.run(Springcloudconsumer80feigndashboard.class,args);

  14. }

  15. }

然后在provider中pom.xml文件中添加:

 
  1. <dependency>

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

  3. <artifactId>spring-boot-starter-actuator</artifactId>

  4. </dependency>

在 springcloud-provider-dept-hystrix-8001 启动类中增加一个bean:

 
  1. @Bean

  2. public ServletRegistrationBean hy()

  3. {

  4. ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());

  5. servletRegistrationBean.addUrlMappings(“/actuator/hystrix.stream”);

  6. return servletRegistrationBean;

  7. }

3.结果

Delay : 该参数用来控制服务器上轮询监控信息的延迟时间,默认为2000毫秒,可以通过配置
该属性来降低客户端的网络和CPU消耗
Title : 该参数对应了头部标题HystrixStream之后的内容,默认会使用具体监控实例URL,可
以通过配置该信息来展示更合适的标题。

 

一圈
实心圆:公有两种含义,他通过颜色的变化代表了实例的健康程度
它的健康程度从绿色<黄色<橙色<红色 递减
该实心圆除了颜色的变化之外,它的大小也会根据实例的请求流量发生变化,流量越
大,该实心圆就越大,所以通过该实心圆的展示,就可以在大量的实例中快速发现故障
实例和高压力实例。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jakeonil

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值