Monitoring microservices with Spring boot Admin server

Spring boot admin server is a web application provided by codecentric. It is used for managing, monitoring spring boot applications.

How it works?

In this, each microservice application considered as client which register itself with spring boot admin server and admin server uses client application’s actuator endpoints to show various status of the application on admin server web interface. Let’s take a breath and walk into the implementation of spring boot admin server.

Implement Admin server setup

Following dependencies need to be added in pom.xml in order to make a spring boot application as admin server:

 <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
        </dependency>

 <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-server-ui</artifactId>
        </dependency>

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-dependencies</artifactId>
                <version>2.1.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

After adding dependencies, add @EnableAdminServer annotation to main application class as below:

@EnableAdminServer
@SpringBootApplication
public class AdminServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(AdminServerApplication.class, args);
    }

}

Just start your application and run it with port you specified in application.properties file, you will see following UI of spring boot admin server.

Admin-server-UI

Ahh! That’s great. You have setup admin server successfully. It’s time to setup admin client so that we can monitor application with admin server.

To setup admin client just add following dependency:

  <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
        </dependency>

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

 <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-dependencies</artifactId>
                <version>2.1.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

After adding, add following properties in application.properties file:


## Application port on which it is running
server.port = 9002

## name of the application which will be shown to admin server UI
spring.application.name=admin-client-application

## Expose all the actuator endpoints to admin client
management.endpoints.web.exposure.include=*

## Admin server URL where admin client will register itself
spring.boot.admin.client.url=http://localhost:9001

## Application details of info-endpoint
info.app.name=admin-client-application
info.app.description=A demo application to illustrate spring boot admin client
info.app.version=1.0

logging.file=/home/decimal/Desktop/console.log

Admin client setup has been done. It’s time to test the same. Start your client application and you will see following:

Admin server UI with client application

In above video, as you can see that admin server is showing client application’s actuator endpoints like info, health status, memory view, thread view, log files as we configured it in application.properties file, http trace etc.

So with this UI, you can monitor your application.

Spring boot admin server provides more features like sending notification, security to your actuators. For more detail you can visit http://codecentric.github.io/spring-boot-admin/2.1.4/

This was all about of configuring admin server to monitor spring boot applications.

Demo project can be found here for admin-server and for admin-client.

2 thoughts on “Monitoring microservices with Spring boot Admin server

  1. Greetings! This is my first visit to your blog! We are a
    collection of volunteers and starting a new project in a community in the same niche.
    Your blog provided us useful information to work on. You have done
    a outstanding job!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s