Exploit Spring Boot Admin — in a good way
By: Preeti Agarwal
Tags: Spring Boot, Spring Boot Admin, Spring Actuator, Application Monitoring

Let us start with what is a Spring Boot Application and then switch to application monitoring

It is an open-source Java-based framework that lets you create quick stand-alone Spring applications. Some of the noticeable features are: -

1. Built-in embedded HTTP servers like Jetty and Tomcat to test web applications

2. Generates boilerplate code, annotations, and complex XML configurations.

Why do we need application monitoring?

As human beings, we like to predict things. Application monitoring is a way to envision and take proactive measures when things are taking wrong turns. There are multiple application monitoring packages available providing extensive details about the application. To name a few: -

1. Apica

2. AppDynamics

3. Dynatrace

However, they do bear a few downsides such as: -

1. They do cost money

2. Monitored application needs to be configured and onboarded

3. May take time to configure correct differentiation between false positive and real error.

Is there anything else available?

Lucky for us Spring Boot comes with multiple actuator endpoints that can help us to monitor and manage the Spring Boot application. Only /actuator/health and /actuator/info are exposed by default. Rest are exposed via JMX. Refer to https://www.baeldung.com/spring-boot-actuators for further details.

So far so good. However, if the application is deployed on multiple nodes/applications, then to monitor every node/application will have a separate actuator endpoint URL. Thus, making monitoring a tedious job.

What is next — Spring Boot Admin?

This brings me to Spring Boot Admin — finally.

Spring Boot Admin is a web-based application, that can be used to manage and monitor Spring Boot applications. It is an open-source library developed/maintained by a company called Codecentric. Git repository can be found at Spring Boot Admin GIT Repo

Each monitored application is called a client, monitoring application is called a server. Client-server interaction can be implemented in the following two ways: -

1. Either Client registers themselves to Spring Boot Server application. The client is responsible for keeping track of the server’s URL.

2. Or Spring Boot Server keeps the information about clients it is going to monitor.

Implementing Spring Boot Admin is easy and needs a minimal amount of coding. Here are some good references for that: -

Spring Boot Admin Documentation

Spring Boot Admin Implementation.

Once Spring Boot Admin implementation is done. By default, it will show the client application’s health, info, JMX metrics. You can see running logs, change log level at a run time, etc.

Customize Spring Boot Admin UI

Spring Boot Admin comes with default actuator endpoints. What if you have custom endpoints or non-standard actuator endpoint, such as /bindings (this endpoint provides support for visualization and control of Spring Cloud Stream)

It would be nice if this can be integrated with Spring Boot Admin UI also. Luckily, it is possible to add custom views to the UI. Here is the link to do so Custom Views

I will suggest: -

1. Clone GIT repo Spring Boot Admin Custom UI.

2. Implement custom views using Vue.js.

3. Add this as a dependency in Spring Boot Admin Server application.

4. Add following properties in Spring Boot Admin Server’s application.properties file

spring.boot.admin.ui.cache.no-cache: true

spring.boot.admin.ui.extension-resource-locations: <location of Spring Boot Admin Custom UI application’s /target/dist folder such as file:@project.basedir@/../spring-boot-admin-sample-custom-ui/target/dist/>

spring.boot.admin.ui.cache-templates: false

spring.boot.admin.ui.extension-resource-locations property tells Spring Boot Admin application that there are some custom extensions located at given path.

If extensions are loaded successfully you will see logs such as “Loaded Spring Boot Admin UI Extension: UiExtension(resourcePath=….”

A word of caution

As Spring Boot Admin Application gives out monitored application’s information and lets you make changes and run time. Make sure to secure it and give access to privileged users only.