Spring Boot(十) Spring Boot 度量指标监控与健康检查

Spring Boot  度量指标监控与健康检查

1 使用 Actuator  检查与监控

1.1 创建项目

1.2 需改 POM  文件,添加依赖

<!--Actuator 坐标依赖 -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

1.3 修改配置文件

# 配置访问端点的根路径
management.endpoints.web.base-path=/actuator
# 配置开启其他端点的 URI
# 开启所有的端点访问: *
# 指定开启端点访问:如: beans,env
management.endpoints.web.exposure.include=*

1.4 各项监控指标接口 URL  介绍

2 使用可视化监控应用 Spring BootAdmin

2.1 使用步骤

Spring BootAdmin 的使用是需要建立服务端与客户端。

服务端:独立的项目,会将搜集到的数据在自己的图形界面中展示。

客户端:需要监控的项目。

对应关系:一个服务端可以监控多个客户端。

2.1.1 搭建服务端

2.1.1.1  创建项目

2.1.1.2  修改 POM  文件

注意:目前在 Spring BootAdmin Starter Server2.1.6 版本中不支持 Spring Boot2.2.x 版本,只支持到 2.1.X

<!--https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-server</artifactId>
	<version>2.1.6</version>
</dependency>

2.1.1.3  修改配置文件

server.port=9090

2.1.1.4  修改启动类

@SpringBootApplication
@EnableAdminServer // 开启 Spring Boot Admin 服务端
public class SpringbootactuatorserverApplication {
	public static void main(String[] args) {
		SpringApplication.run(SpringbootactuatorserverApplication.class, args);
	}
}

2.2 搭建客户端

2.2.1 修改 POM  文件

<!--https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-client -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-client</artifactId>
	<version>2.1.6</version>
</dependency>

2.2.2 修改配置文件

# 配置访问端点的根路径
management.endpoints.web.base-path=/actuator
# 配置开启其他端点的 URI
# 开启所有的端点访问: *
# 指定开启端点访问:如: beans,env
management.endpoints.web.exposure.include=*
# 指定服务端的访问地址
spring.boot.admin.client.url=http://localhost:9090

2.2.3 效果图

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

plenilune-望月

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

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

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

打赏作者

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

抵扣说明:

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

余额充值