当前位置:网站首页>监控页面部署
监控页面部署
2022-07-30 03:25:00 【Leon_Jinhai_Sun】
除了对服务的降级和熔断处理,我们也可以对其进行实时监控,只需要安装监控页面即可,这里我们创建一个新的项目,导入依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
<version>2.2.10.RELEASE</version>
</dependency>接着添加配置文件:
server:
port: 8900
hystrix:
dashboard:
# 将localhost添加到白名单,默认是不允许的
proxy-stream-allow-list: "localhost"接着创建主类,注意需要添加@EnableHystrixDashboard注解开启管理页面:
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashBoardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashBoardApplication.class, args);
}
}启动Hystrix管理页面服务,然后我们需要在要进行监控的服务中添加Actuator依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Actuator是SpringBoot程序的监控系统,可以实现健康检查,记录信息等。在使用之前需要引入spring-boot-starter-actuator,并做简单的配置即可。
添加此依赖后,我们可以在IDEA中查看运行情况:

然后在配置文件中配置Actuator添加暴露:
management:
endpoints:
web:
exposure:
include: '*'接着我们打开刚刚启动的管理页面,地址为:http://localhost:8900/hystrix/

在中间填写要监控的服务:比如借阅服务:http://localhost:8301/actuator/hystrix.stream,注意后面要添加/actuator/hystrix.stream,然后点击Monitor Stream即可进入监控页面:

可以看到现在都是Loading状态,这是因为还没有开始统计,我们现在尝试调用几次我们的服务:

可以看到,在调用之后,监控页面出现了信息:

可以看到5次访问都是正常的,所以显示为绿色,接着我们来尝试将图书服务关闭,这样就会导致服务降级甚至熔断,然后再多次访问此服务看看监控会如何变化:

可以看到,错误率直接飙升到100%,并且一段时间内持续出现错误,中心的圆圈也变成了红色,我们继续进行访问:

在出现大量错误的情况下保持持续访问,可以看到此时已经将服务熔断,Circuit更改为Open状态,并且图中的圆圈也变得更大,表示压力在持续上升。
边栏推荐
- (RCE)远程代码/命令执行漏洞漏洞练习
- OA项目之待开会议&历史会议&所有会议
- Three years of experience will only be a little bit (functional testing), and you may not even be able to find a job after resigning.
- WPF引入 ttf 图标文件使用记录
- 群论-Burnside引理与Polya定理 三千字
- 判断Object是否依赖于名叫“XX“的资产
- QT基础第三天(3)widget,dialog和mainwindow
- JIT vs AOT
- un7.29:Linux——centos中如何安装与配置redis?
- JUC (8) : synchronized little exercise
猜你喜欢
随机推荐
One book 1922 - table tennis
gnss rtcm rtklib Ntrip...
复合类型--引用,指针
SQL Server中如何在date类型中提取年、月、日数据
【科研工具的使用】A
sql中 exists的用法
JUC (four): five/six states of shorthand thread
JIT VS AOT
淘宝/天猫获取卖出的商品订单列表 API
Ansible简介(详细)特性+优点+设计理念+应用领域+系统架构+工作原理+任务执行流程
北京bgp机房和普通机房的区别
【无标题】
QT based on the third day (3) widget, dialog and mainwindow
【Flink】从开发到生产上线,如何确定集群规划大小 ?
记录NLP各种资源网址
CMake的安装和测试
JUC(八):synchronized小练习
Solve The problem of Google browser cross-domain has had been blocked by CORS policy: The request The client is not a secure context and The resou
YOLOv7的一些理解
leetcode每天5题-Day01









