# adc-monitor-admin
**Repository Path**: michaelcheuang/adc-monitor-admin
## Basic Information
- **Project Name**: adc-monitor-admin
- **Description**: srping boot admin 服务监控
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-08-04
- **Last Updated**: 2023-08-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 服务监控 Spring Boot Admin搭建
## 基本介绍
### 1. 服务监控
服务监控就是监视当前系统应用状态、内存、线程、堆栈、日志等等相关信息,主要目的在服务出现问题或者快要出现问题时能够准确快速地发现以减小影响范围。
服务监控在微服务改造过程中的重要性不言而喻,没有强大的监控能力,改造成微服务架构后,就无法掌控各个不同服务的情况,在遇到调用失败时,如果不能快速发现系统的问题,对于业务来说就是一场灾难。
#### 2. Spring Boot Admin 服务监控管理
Spring Boot Admin 是一个针对 Spring Boot 的 Actuator 接口进行 UI 美化封装的监控工具。他可以:在列表中浏览所有被监控Spring Boot项目的基本信息,详细的 Health 信息、内存信息、JVM信息、垃圾回收信息、各种配置信息(比如数据源、缓存列表和命中率)等,还可以直接修改 logger 的 level。
Spring Boot Admin 是由 Client 端和 Server 端组成,在 Spring Boot 项目中,Spring Boot Admin作为 Server 端,其他的要被监控的应用作为 Client 端。
## 搭建spring boot Admin
### 1. 搭建 Server 端
我们新建一个 cloud-monitor 的服务
##### 1.1、添加依赖
```xml
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-security
de.codecentric
spring-boot-admin-starter-server
2.6.7
de.codecentric
spring-boot-admin-starter-client
2.6.7
```
此处为'spring-boot-admin-starter-server'的版本使用2.6.7,原因是项目是基于
```xml
org.springframework.boot
spring-boot-starter-parent
2.6.7
```
创建的spring boot admin工程,日志使用log4j2组件。将服务段也作为一个服务监控起来,因此在此引如了'spring-boot-admin-starter-client',并且做了登录认证,引入了'spring-boot-starter-security'
#### 1.2 配置启动
在启动文件中配置
```yaml
server:
port: 9090
spring:
application:
name: adc-monitor-admin
--- # Actuator 监控端点的配置项
management:
endpoints:
web:
# Actuator 提供的 API 接口的根目录。默认为 /actuator
base-path: /actuator
exposure:
include: '*'
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 增加客户端开关
enabled: true
# 设置 Spring Boot Admin Server 地址
url: http://127.0.0.1:9090/admin
instance:
service-host-type: IP
username: admin
password: 123456
```
#### 1.3 启动验证







### 2.搭建 Client 端
#### 2.1 添加依赖
```xml
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-actuator
de.codecentric
spring-boot-admin-starter-client
2.6.7
```
#### 2.2 增加配置
```yaml
--- # 监控中心配置
spring:
boot:
admin:
client:
# 增加客户端开关
enabled: true
url: http://127.0.0.1:9090/admin
instance:
service-host-type: IP
username: admin
password: 123456
#通过下面的配置启用所有的监控端点,默认情况下,这些端点是禁用的;
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
```
启动客户端后,服务客户端的服务就注册上去了,如下图

