当前位置:   article > 正文

SpringBoot:Boot Admin Server_spring-boot-admin-starter-server

spring-boot-admin-starter-server

目录

一、创建项目

二、基础设置

三、注册客户端

四、监控项目


指标监控可视化文档:用于管理 Spring Boot 应用程序的管理 UIicon-default.png?t=M85Bhttps://github.com/codecentric/spring-boot-adminSpring Boot Admin Reference Guideicon-default.png?t=M85Bhttps://codecentric.github.io/spring-boot-admin/2.5.1/#getting-started


一、创建项目

 

 就勾选Spring Web项目即可

 

二、基础设置

(1) 依赖引入

  1. <dependency>
  2. <groupId>de.codecentric</groupId>
  3. <artifactId>spring-boot-admin-starter-server</artifactId>
  4. <version>2.5.1</version>
  5. </dependency>

(2) 开启服务器监控功能

  1. import de.codecentric.boot.admin.server.config.EnableAdminServer;
  2. import org.springframework.boot.SpringApplication;
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;
  4. @EnableAdminServer //开启服务器监控功能
  5. @SpringBootApplication
  6. public class BootAdminServerApplication {
  7. public static void main(String[] args) {
  8. SpringApplication.run(BootAdminServerApplication.class, args);
  9. }
  10. }

(3) SpringBoot配置文件

server.port=8888

(4) 启动项目

浏览器输入:http://localhost:8888/

打开的管理页面如下:

三、注册客户端

客户端中的数据需要被服务器收集

(1) 添加依赖

  1. <dependency>
  2. <groupId>de.codecentric</groupId>
  3. <artifactId>spring-boot-admin-starter-client</artifactId>
  4. <version>2.5.1</version>
  5. </dependency>

(2) 客户端把数据传递给服务器

在需要监控的项目中的application.yaml配置:(注意是另一个项目application.yaml,因为要监控另一个项目)

  1. spring:
  2. boot:
  3. admin:
  4. client:
  5. url: http://localhost:8888

开启所有端点的监控,同样是在需要被监控的项目中进行配置(这里还是application.yaml)

  1. # management 是所有actuator的配置
  2. # management.endpoint.端点名.xxxx 对某个端点的具体配置
  3. management:
  4. endpoints:
  5. enabled-by-default: true #默认开启所有监控端点 true
  6. web:
  7. exposure:
  8. include: '*' # 以web方式暴露所有端点

四、监控项目

客户端和服务器连接好后,就可以打开SpringBoot Admin Server的管理界面了,实时监控项目

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/856542
推荐阅读
相关标签
  

闽ICP备14008679号