SpringBootMonitor: 改造SpringBootAdmin的单机版监控工具,适配SpringBootAdmin前端页面的接口,无需再部署Server,本机直接读取Actuator的信息。

License JDK 1.8 Maven Central

[](#spring-boot-monitor%E9%A1%B9%E7%9B%AE%E7%AE%80%E4%BB%8B)Spring-boot-monitor项目简介

在使用Spring Boot Actuator的时候,你是否想要一套界面来方便查看应用的指标呢?

在你搜索相关的ui的时候,是不是发现Spring boot Admin这个监控工具特别火呢?

Spring boot Admin的ui是真的好看,可是它却令人又爱又恨,Server ?!

是的,它必须要求你重新部署一个应用,来做Admin Server,被监控的机器做Admin Client!简直遭罪啊,如果我只想要一个鸡腿,你却给我送个鸡爪子,不知道我不爱吃鸡爪么?我得部署个Server,而且指标数据还得从client传到server,再由Server传给前端,中间得网络开销也不小(metrics接口得数据特别大,可能查询这个接口要几秒)。

所以,我就想如何把Spring boot Admin部署到单机,或许有人说,可以把Server和Client都整合到一个应用里。累不累!数据要在localhost里转一圈,还特别浪费资源,我只想要一套界面而已!

这时候Spring Boot Monitor这个工具就应运而生,它把Spring boot Admin的界面拿了出来,并修改了数据来源,直接从Actuator拿数据,就是这么简单!对代码无任何侵入!和Spring boot Admin的功能一模一样。

[](#gitee)Gitee

[](#github)Github

[](#get-started)Get Started

[](#%E4%B8%BB%E8%A6%81%E5%8A%9F%E8%83%BD)主要功能

v0.0.1:

  1. 单机监控SpringBoot应用指标;
  2. 无需额外配置;
  3. 将前端资源归纳到/monitor路径中,隔离其他资源;
  4. 去掉了Spring boot Admin的Server;
  5. 去掉了Spring boot Admin对thymyleaf的依赖;
  6. 去掉了Spring boot Admin的event流。

v0.0.2:

  1. 增加events接口,显示journal信息。

v0.0.3:

  1. 增加Spring boot admin的多语言支持特性,支持中文。
  2. 支持日志文件查看和下载
  3. 使用cookie实现简单的登陆控制。

v0.0.4:

  1. 修复logfile不能正常显示问题

[](#%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E)使用说明

jar包已经上传到maven中央仓库。 https://search.maven.org/search?q=spring-boot-monitor ,groupId为cn.pomit。

使用文档地址

[](#maven%E4%BE%9D%E8%B5%96)maven依赖

<dependency>
<groupId>cn.pomit</groupId>
<artifactId>spring-boot-monitor</artifactId>
<version>0.0.4</version>
</dependency>

[](#%E5%90%AF%E5%8A%A8)启动

引入依赖即可。使用AutoConfiguration自动加载spring-boot-monitor相关配置。

[](#%E9%85%8D%E7%BD%AEactuator)配置actuator

同样,使用actuator还需加上actuator的配置,开放endpoints。

management.endpoints.web.exposure.include=*

[](#%E8%AE%BF%E9%97%AE%E6%96%B9%E5%BC%8F)访问方式

如果当前的应用地址为http://127.0.0.1:8080, spring-boot-monitor的访问地址为:http://127.0.0.1:8080/monitor。

其他操作则是前端页面操作。和spring-boot-admin完全一样。

[](#%E6%9F%A5%E7%9C%8B%E6%97%A5%E5%BF%97)查看日志

如果要查看日志文件,项目需要增加日志的配置,比如:

logging.file=./log/monitor.log
logging.pattern.file="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID}){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"

[](#%E7%99%BB%E5%BD%95%E6%8E%A7%E5%88%B6)登录控制

如果要使用用户名密码进行访问控制,只需要配置参数即可:

spring.boot.monitor.username=cff
spring.boot.monitor.password=123456
spring.boot.monitor.salt=pomit

其中,spring.boot.monitor.salt为可选参数,不配做默认值是pomit;spring.boot.monitor.username和spring.boot.monitor.password其中一个不配置,则默认为不进行访问控制。

[](#get-started-1)Get-Started

[](#%E7%89%88%E6%9D%83%E5%A3%B0%E6%98%8E)版权声明

spring-boot-monitor使用 Apache License 2.0 协议.

[](#%E4%BD%9C%E8%80%85%E4%BF%A1%E6%81%AF)作者信息

作者博客:https://blog.csdn.net/feiyangtianyao

个人网站:https://www.pomit.cn

作者邮箱: fufeixiaoyu@163.com

[](#license)License

Apache License V2


原网址: 访问
创建于: 2023-07-05 01:17:14
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论