当前位置: 首页 > news >正文

SpringBoot整合Admin服务监控(图文详细)

SpringBoot整合Admin服务监控组件

1 SpringBootAdmin 简介

1.1 概述

  • SpringBootAdmin 是一个非常好用的监控和管理的开源组件,该组件能够将 Actuator 中的信息进行界面化的展示,也可以监控所有 Spring Boot 应用的健康状况,提供实时警报功能。

1.2 功能特性

  • 显示应用程序的监控状态
  • 应用程序上下线监控
  • 查看 JVM,线程信息
  • 可视化的查看日志以及下载日志文件
  • 动态切换日志级别
  • Http 请求信息跟踪

2 Server端整合

2.1 添加pom配置

<!--Admin+Actuator 健康信息健康-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>

2.2 配置yaml参数

# Boot参数配置信息
spring:application:name: xs-monitor-serverprofiles:active: devboot:admin:monitor:default-timeout: 5000client:url: http://localhost:${server.port}${spring.boot.admin.context-path}#注册实例 优先使用IPinstance:prefer-ip: true# 监控访问前缀信息context-path: /admin# Actuator 监控端点的配置项
management:health:mail:enabled: falseendpoints:web:base-path: /actuatorexposure:include: '*'endpoint:health:show-details: alwayslogfile:external-file: ${user.dir}/logs/${spring.profiles.active}/xs-monitor/xs-monitor-server/sys-console.log

2.3 编辑config配置信息

package com.xs.monitor.config;import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;import java.util.concurrent.Executor;// @EnableAdminServer 添加此注解表示启用Admin监控
@Configuration
@EnableAdminServer
public class AdminServerConfig {@Lazy@Bean(name = TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME)@ConditionalOnMissingBean(Executor.class)public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {return builder.build();}}

2.4 启动Server

请添加图片描述

2.5 管理端查看

请添加图片描述

3 Client业务端整合

3.1 添加pom配置

  • 业务端只需要client组件,不再需要Server端
<!--Spring Boot Admin 健康模块-->
<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

3.2 配置yaml参数

#配置
spring:application:name: xs-monitor-clientprofiles:active: devboot:admin:client:url: http://localhost:1000/admin#注册实例 优先使用IPinstance:prefer-ip: true# Actuator 监控端点的配置项
management:health:mail:enabled: falseendpoints:web:base-path: /actuatorexposure:include: '*'endpoint:health:show-details: alwayslogfile:external-file: ${user.dir}/logs/${spring.profiles.active}/xs-monitor/xs-monitor-client/sys-console.log

3.3 新增Config配置

package com.xs.monitor.config;import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;import java.util.concurrent.Executor;@Configuration
public class AdminServerConfig {@Lazy@Bean(name = TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME)@ConditionalOnMissingBean(Executor.class)public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {return builder.build();}}

3.4 启动Client业务端

请添加图片描述

3.5 查看管理端【server地址】

请添加图片描述

4 整体演示

请添加图片描述
请添加图片描述
请添加图片描述

http://www.lryc.cn/news/48320.html

相关文章:

  • 设计模式-结构型模式-组合模式
  • VScode开发工具总结
  • opencv 解码视频流,c++ 代码写法
  • Android 12.0 修改wifi信号强度
  • Linux——容器简介
  • CMOS图像传感器——pipeline像素控制
  • AI工具(ChatGPT)常用指令,持续更新...
  • 36--Django-项目实战-全栈开发-基于django+drf+vue+elementUI企业级项目开发流程-前台项目准备
  • 游戏算法-游戏AI行为树,python实现
  • 【新2023Q2模拟题JAVA】华为OD机试 - 矩阵最值 or 计算二维矩阵的最大值
  • 递归过程与递归工作栈
  • B 树的简单认识
  • 【大数据Hive3.x数仓开发】窗口函数案例:连续N次登录的用户;级联累加求和;分组TopN
  • openpyxl库自动填充excel实例分享
  • ICLR2021清华团队做的知识蒸馏提升detector的点的工作paper 小陈读论文系列
  • Java核心技术知识点笔记—集合框架
  • Rsync数据同步工具
  • redux小结
  • 【Python】【进阶篇】十、Pygame的Font文本和字体
  • 【从零开始学习 UVM】10.8、UVM TLM —— UVM TLM Example
  • 获取自己所上传资源的下载量
  • Aspose.cells模板导出使用记录
  • AcWing——糖果传递
  • Redis中的单线程模型
  • Python函数默认参数设置(超级详细)
  • 人工智能如何赋能业务创新?安克创新有话要说
  • 如何学习与学习的本质
  • C++ deque容器
  • HashMap的底层原理
  • Django 4.0文档学习(四)