SpringBoot Admin 2.1.6 监控管理使用

一、什么是Spring Boot Admin【SpringBoot Admin 2.1.6 监控管理使用】Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序。 应用程序作为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 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
  • 状态变更通知(通过电子邮件,Slack,Hipchat,......)
  • 状态更改的事件日志(非持久性)
二、使用 1、创建Spring Boot Admin Server
  • 引入依赖
org.springframework.boot spring-boot-starter-web 2.1.9.RELEASE de.codecentric spring-boot-admin-starter-server 2.1.6 de.codecentric spring-boot-admin-server-ui 2.1.6 org.springframework.boot spring-boot-starter-security 2.1.9.RELEASE

  • 配置文件
spring: # 配置SBA Client连接的安全账号密码 security: user: name: admin password: admin boot: admin: ui: # 修改网页显示的tab标题 title: "应用监控管理" # 修改网页的brand的图标和标题 # brand: "SpringBoot Admin 2.1.6 监控管理使用
文章图片
登陆配置的账号密码 ,即可进入admin管理界面
2、Spring Boot Admin Client搭建
  • 引入依赖
de.codecentric spring-boot-admin-starter-client 2.1.6

  • 配置文件
spring: boot: admin: client: # 这个URL地址是SBA Server的服务地址,你需要将你的应用注册到该地址上 url: http://localhost:7070 # 配置连接到监测管理平台的Security安全密码 username: admin password: admin#需要暴露监控端口给spring boot admin server访问 management: endpoint: health: show-details: always endpoints: web: exposure: include: "*"

客户端项目中security.enabled:true时 即客户端开启了security验证则会出现类似以下401无权限状态
解决方式:通过页面F12查看报401接口路径在security.ignored.paths中进行方行如:
spring: security: enabled: true login-url: /login logout-url: /logout sso: enabled: false#启用单点登录 host: http://localhost:8070/auth# 认证服务器实际IP、HOST ignored: paths: - /api/health #不须认证的URL配置 - /swagger* - /v2/api-docs - /actuator/* - /actuator/metrics/*#springbootAdmin 放开路由权限 - /actuator/env/*#springbootAdmin 放开路由权限 - /actuator/jolokia/*#springbootAdmin 放开路由权限

SpringBoot Admin 2.1.6 监控管理使用
文章图片

启动测试
查看被监控的服务详细信息
SpringBoot Admin 2.1.6 监控管理使用
文章图片

    推荐阅读