springboot Actuator的指标监控可视化功能详解

网友投稿 265 2022-12-15

springboot Actuator的指标监控可视化功能详解

springboot为我们提供了丰富的指标监控功能SpringBoot Actuator

SpringBoot Actuator是springboot为简化我们对微服务项目的监控功能抽取出来的模块,使得我们每个微服务快速引用即可获得生产界别的应用监控、审计等功能。

后序文章会更新使用 我们先来看看怎么可视化

我们可以通过github上的开源项目

这里

我们创建一个springboot项目 作为可视化的服务端

使用新功能首先都是引入依赖

需要web项目

de.codecentric

spring-boot-admin-starter-server

2.4.3

org.springframework.boot

spring-boot-starter-web

开启我们的监控服务 @EnableAdminServer

/**

* @EnableAdminServer

* 开启监控功能

*/

@EnableAdminServer

@SpringBootApplication

public class BootAdminserverApplication {

public static void main(String[] args) {

SpringApplication.run(BootAdminserverApplication.class, args);

}

}

避免端口冲突 更改端口号

server.port=8000

启动测试一下

访问一下

http://localhost:8000

显示如下界面即启动成功

这时需要在我们的其他微服务应用中添加客户端依赖注册进来

需要注册进来的应用添加客户端依赖

de.codecentric

<artifactId>spring-boot-admin-starter-client

2.4.3

我们现在拿一个以前写过的springboot项目 充当客户端

我们在以前的项目中引入两个依赖

第一个依赖开启springboot的指标监控actuator需要的jar包

org.springframework.boot

spring-boot-starter-actuator

de.codecentric

spring-boot-admin-starter-client

2.4.3

我们在配置文件中增加配置信息

sprinhttp://g:

boot:

admin:

client: # 可视化服务的地址 我们注册到哪里的端口号

url: http://localhost:8000

applihttp://cation: #应用的名字

name: boot-web

#management 是所有actuator的配置

#management.endpoint.端点名.xxx 对某个端点的具体配置

management:

endpoints:

enabled-by-default: true #默认开启所有监控端点

web:

exposure:

include: '*' #以web方式暴露端点

我们启动客户端应用 回来查看监控服务器页面

我们发现程序注册进来了

我们可以点击这个应用墙程序进来 看见详细信息

这只是简单实例详细的信息大家可以看github的开源项目介绍

项目

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:java合成模式之神奇的树结构
下一篇:java中ThreadLocal的基本原理
相关文章

 发表评论

暂时没有评论,来抢沙发吧~