Monitor, Audit and Gather Metrix of a Spring Application
Go Back to Course Outline This time we will discuss how we can monitor, audit and gather metrics on a spring boot application. ...
https://www.czetsuyatech.com/2019/08/spring-microservice-monitor-audit-gather-application-metrix.html
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
- Using the Sprint STS development environment, create a Spring starter project. Add the following dependencies:
- spring-boot-starter-web
- spring-boot-admin-starter-server
- spring-boot-admin-starter-client
- spring-boot-starter-security
- spring-boot-devtools
- After the project is created, add the spring-boot-maven-plugin in your pom.xml with goal=build-info.
- Configure application.properties. See file below for description.
- Annotate your Spring boot class with @EnableAdminServer.
- 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.
- Add spring-boot-admin-starter-client dependency.
- Add the credentials to connect to the admin server in the application.json file. See file below.
References
- https://github.com/czetsuya/Terawarehouse-Admin-Server
- https://github.com/terawarehouse/terawarehouse-catalog
- https://github.com/codecentric/spring-boot-admin
- https://codecentric.github.io/spring-boot-admin/current
- https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html
Post a Comment