前言
Spring Boot Admin 是一个管理和监控Spring Boot 应用程序的开源软件。应用程序作为Spring Boot Admin Client向为Spring Boot Admin Server注册(通过HTTP)或使用SpringCloud注册中心(例如Eureka,Consul)发现。UI是Vue.js应用程序,展示Spring Boot Admin Client的Actuator端点上的一些监控。服务端采用Spring WebFlux + Netty的方式。 是一个针对spring-boot的actuator接口进行UI美化封装的监控工具。可以在列表中浏览所有被监控spring-boot项目的基本信息,详细的Health信息、内存信息、JVM信息、垃圾回收信息、各种配置信息(比如数据源、缓存列表和命中率)等,还可以直接修改logger的level。Actuator监控可参考SpringBoot 使用Actuator监控
搭建 Spring Boot Admin Server
pom.xml文件
spring-boot-admin-server-ui在2.0之后采用了Vue.js应用程序。
1 | <dependencies> |
启动类
添加注解@EnableAdminServer。
1 |
|
启动项目
启动项目后访问,可以看到页面。
搭建 Spring Boot Admin Client
pom.xml文件
服务端采用Spring WebFlux + Netty的方式,我们的项目使用web+Tomcat方式。
1 | <dependencies> |
配置文件
- 因为spring-boot-admin-starter-client依赖包含spring-boot-starter-actuator依赖,所以这里可以直接配置actuator属性。
- spring.boot.admin.client.url:要注册的Spring Boot Admin Server的URL。
- management.endpoints.web.exposure.include:* 代表公开所有这些端点。
- management.endpoints.web.exposure.exclude:设置屏蔽的端点。
- info为端点项目信息。
- 因为本机项目,需要设置不同的端口。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23server:
port: 8083
spring:
boot:
admin:
client:
url: http://localhost:8080
instance:
name: ReactiveCrud
info:
name: spring-boot-actuator-test
description: springboot-admin-client-description
version: 1.0.0
management:
endpoints:
web:
exposure:
include: "*"
#屏蔽env,beans监控点
exclude: env,beans启动项目