Spring Boot Admin Server & Client —implementation with example

Payal Chattaraj
5 min readAug 22, 2020

If you are exploring solutions for monitoring Spring Boot based microservices, this article will be helpful for building quick proof of concept.

Use case

Spring Boot Admin server is useful to create a quick dashboard to monitor microservice applications with minimal coding. It provides simple, clean visuals along with other monitoring features built on Actuator — Production-ready features of Spring Boot. This article is a step-by-step guide to setup a basic Spring Boot Admin server application and register a client.

What we will be doing on this guide

  • Setup a simple REST API application called plantfinder-api which will be registered as a client
  • Setup a microservice called admin-console and use it as Spring Boot Admin server using- this will be the dashboard for monitoring the plantfinder-api application

Lets start!

Setup plantfinder-api microservice

Go to https://start.spring.io/ and type in following

Note: Project metadata can be changed as per preference.

Three dependencies are needed for this application:

  • Spring Web since this is a REST based microservice
  • Spring Boot Actuator to add support for actuator endpoints
  • Spring Boot Admin client so this application can be registered as a client to a Spring Boot Admin Server

After generating the project, the same can be opened in an IDE and the structure will appears as below:

I have added three classes — PlantFinderMainController, AppConfig and Plant to implement two rest endpoints —

  • GET “/plantfinder-api/plants” — Get all available plants
  • POST “/plantfinder-api/add” — Add a plant

The code can be accessed in Github location mentioned at the end of the article.

Lets try endpoint — localhost:8081/plantfinder-api/plants from Postman console, after starting application and we will be able to receive a success response:

We will be adding some configurations to the application.properties file to register it as a client to Spring Boot Admin Server application. We will comeback to that later.

Setup admin-console microservice

Go to https://start.spring.io/ and type in following

Three dependencies are needed for this application:

  • Spring Web to host the admin service dashboard
  • Spring Boot Admin Server to use it as a Spring Boot Admin Server application
  • Java Mail Sender to enable notifications for monitoring

After generating the project, the same can be opened in an IDE and the structure will appears as below:

Lets add following to enable it as a Spring Boot Admin Server application:

  1. Add “@EnableAdminServer” to the AdminConsoleApplication class

2. Add following configurations to application.properties

The email specific configurations are required to send notification when one of the applications being monitored encounter certain events, we will see an example shortly.

When we run the application, we will be able to access the dashboard at localhost:8092 as below:

As we can see right now, there are no client applications registered to be monitored. Lets register our plantfinder-api application as a client, to achieve that we will add following to the application.properties file of plantfinder-api application

The highlighted configurations are required for the registration. As Spring Boot Admin Server uses actuator endpoints to provide monitoring data, we need those endpoints to be exposed from the application. In real world cases we should use custom security rules to expose these endpoints, for simplicity of this guide I have not included those here. Also note that as our admin-console application is hosted on port 8092, the client url reflects that.

Once we restart our plantfinder-api application we will be able to see the application registered in the admin-console as follows:

We can click on the application to see detailed insights, some examples are as follows:

As we have configured notification based settings we will receive notification as client application goes down. To test, stop plantfinder-api application and an email will be sent as follows:

Further customization are possible to refine it based on application need.

Troubleshooting

I have put together some common issues one might come across to run the above applications and while trying this guide:

  • Email not going out using Gmail SMTP with certificate exception: Check antivirus software settings, often SMTP based communications are blocked for security reasons
  • Client application service is not showing up in admin server: Check pom.xml and ensure spring-boot-admin-starter-client and spring-boot-admin-starter-server are using same versions
  • Actuator end points are not working for client application: Ensure no existing custom security rule within the application is blocking actuator endpoints

Documentations for Spring Boot Admin Server & Client for further reading

Github locations for the code used in this tutorial

Thanks for reading, hope this helps!

--

--

Payal Chattaraj

Lets transform businesses with the power of technology!