Spring Boot Admin - codecentric AG Blog
With this blog post I want to show you a small administration tool.
Before showing you the project I want to give you a short explanation of the background. In the beginning of this year we decided to migrate all our batch environment to Spring Boot. This means that, from then on, instead of one big JVM with n batches running on it, we have n JVMs that can be deployed, started and managed separately. After this migration we were searching for a way to get an overview of all running batch instances. It also would have been great to do administrative tasks on each instance. This could be, i.e. setting log level at runtime. This was the birth of this small admin tool I want to show you in the next sections.
The tool should first of all provide the following features
- Overview over all running instances, including …
- Version number
- Detail view with information of the JVM
- Download of log files
- Viewing / Editing log levels
As all batches are also Spring Boot applications and I was excited about this, the admin application should also be a Spring Boot app. The name of this new application is spring-boot-admin. The core framework of this application is the Spring Framework, as you already assumed. On client side I use AngularJS. All Spring Boot REST-endpoints are called and visualized with AngularJS. The overall design of the frontend is borrowed from SpringIO (HTML structure / CSS).
There is a client package that is mandatory for every shown/managed application: spring-boot-starter-admin-client. This client package provides all necessary dependencies that spring-boot-admin expects from “it’s” applications. This client package also includes an AutoConfiguration that loads some REST-controllers in the application context. It also includes a registrator that is responsible for registering an application at the spring-boot-admin.
Beside this dependency to spring-boot-starter-admin-client, each application that want to be managed by spring-boot-admin must have at least two properties in it’s application.properties file. The first one is the URL of the spring-boot-admin to know where to send the request for it’s registration. The other one is the ID, that must be unique and will be used as key inside the registry of spring-boot-admin.
At last, I want to show you screenshots of the tool to give you some impressions.
This is the overview that is a listing of all registered applications.
Here you find a details view showing visualization of data of the /metrics endpoint provided by the actuator package.
So set log levels at runtime, I use jolokia to work with JMX beans via a provided REST api. The default logging framework of Spring Boot, logback, provides a JMXConfigurator that publishes a JMX bean for logger configuration. With this, it is possible to change logger settings via REST.
For the future, I think a small monitoring/notification feature would be nice. I mean something that monitors the status of each application and, i.e. sends an email if something unwanted happens.
At the end I have to say that, of course, all that stuff is OpenSource and can be found at GitHub. Pull requests with new features are very welcome.