no

How to Monitor, Audit and Gather Metrics on a Spring Boot Application

Go Back to Course Outline This time we will discuss how we can monitor, audit and gather metrics on a spring boot application. ...


Go Back to Course Outline

This time we will discuss how we can monitor, audit and gather metrics on a spring boot application.

When dealing with a multi-component application such as in a microservice architecture it is very important to manage, audit, gather metrics, health check-up and monitor the different micro-service applications or in our example Spring boot applications. With Spring boot framework there is a library that is easily accessible and configured to provide such production-ready features which are the Spring Boot Actuator. These features are accessible via JMX or HTTP endpoints.

In addition, there is also a community project which is known as Spring Admin that provides an administration that provides a centralized place to access the details submitted by all the registered clients.

In this blog, we will set up the Spring Admin server and a sample client.

Setup the Spring Admin Server

  1. Using the Sprint STS development environment, create a Spring starter project. Add the following dependencies:
    1. spring-boot-starter-web
    2. spring-boot-admin-starter-server
    3. spring-boot-admin-starter-client
    4. spring-boot-starter-security
    5. spring-boot-devtools
  2. After the project is created, add the spring-boot-maven-plugin in your pom.xml with goal=build-info.
  3. Configure application.properties. See file below for description.
  4. Annotate your Spring boot class with @EnableAdminServer.
  5. Create a security configuration class. See class below.

Setup the Client

If you will notice the server project contains an admin starter client dependency as well as configuration to connect to itself. It means that we are setting up the server as a client itself.

Here are the steps to set up a client.
  1. Add spring-boot-admin-starter-client dependency.
  2. Add the credentials to connect to the admin server in the application.json file. See file below.

References

Related

coding 8850279699907440274

Post a Comment Default Comments

item