
一、前言Spring Boot Admin是一个开源社区项目用于管理和监控SpringBoot应用程序。 应用程序作为Spring Boot Admin Client向为Spring Boot Admin Server注册通过HTTP或使用SpringCloud注册中心例如EurekaConsul发现。 UI是的Vue.js应用程序展示Spring Boot Admin Client的Actuator端点上的一些监控。服务端采用Spring WebFlux Netty的方式。Spring Boot Admin为注册的应用程序提供以下功能显示健康状况 显示详细信息例如 JVM和内存指标 micrometer.io指标 数据源指标 缓存指标 显示构建信息编号 关注并下载日志文件 查看jvm system-和environment-properties 查看Spring Boot配置属性 支持Spring Cloud的postable / env-和/ refresh-endpoint 轻松的日志级管理 与JMX-beans交互 查看线程转储 查看http-traces 查看auditevents 查看http-endpoints 查看计划任务 查看和删除活动会话使用spring-session 查看Flyway / Liquibase数据库迁移 下载heapdump 状态变更通知通过电子邮件SlackHipchat...... 状态更改的事件日志非持久性二、admin-server2.1 引入依赖dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server --dependencygroupIdde.codecentric/groupIdartifactIdspring-boot-admin-starter-server/artifactIdversion2.2.4/version/dependency注意: 由于 Spring Boot 版本使用的是 2.2.xSpring Boot Admin Server 的版本也要用 2.2.x千万别乱搞Admin Client也是一样。2.2 配置application.ymlserver:port:8080#servlet:# context-path: /admin-serverspring:application:name:BootAdminServer2.3 启动类增加EnableAdminServer修改启动类增加EnableAdminServer具体如下SpringBootApplicationEnableAdminServerpublicclassAdminServerApplication{publicstaticvoidmain(String[]args){SpringApplication.run(AdminServerApplication.class,args);}}2.4 启动服务端启动服务然后访问http://localhost:8080三、admin-client3.1 引入依赖!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-client --dependencygroupIdde.codecentric/groupIdartifactIdspring-boot-admin-starter-client/artifactIdversion2.2.4/version/dependency3.2 配置application.ymlmanagement:endpoints:web:exposure:include:*endpoint:health:show-details:alwaysserver:port:8081spring:application:name:BootClientServerboot:admin:client:url:http://localhost:80803.3 启动客户端启动服务然后访问服务端http://localhost:8080四、辅助功能4.1 添加邮件预警需要在客户端yml里配置更为详细的信息info:app:name:project.namedescription:project.descriptionversion:project.versionspring-boot-version:spring-boot.version具体服务端监控到信息如下图4.2 添加邮件预警1首先添加邮件依赖dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId/dependency2服务端的yml中配置邮件预警spring:mail:host:smtp.126.comusername:wno704126.compassword:xxxproperties:mail:smtp:auth:truestarttls:enable:truerequired:trueboot:admin:notify:mail:from:wno704126.comto:wno704qq.com邮件的具体使用方法可参考《使用Spring Boot发送邮件》3当被检测的应用关停的时候收到如下邮件