How Can We Monitor Our Spring Boot Microservices?

  • As we are working on many microservices in many environments. It’s getting hard to monitor all of them.
  • We could have many questions such as “A microservice is down? which microservice version is working? I need to investigate logs but How can I change the log level? I changed the config but Was it deployed or not?”
  • We can see logs on admin-server as well.
  • Spring Boot Admin Server can be an answer to these questions.
  • You can also send a message to Slack/PagerDuty/OpsGenie etc. when your application is down/up etc.
  • If you have already implemented eureka, you can also implement the admin server easily.
  • If you don’t have a eureka implementation, you can implement it as well.
  • In our blog, we will implement without eureka.

Create a Spring Boot Application for Admin Server

  • First of all, we add
@EnableAdminServer
  • We need to add these dependencies in pom.xml
  • If you want to add a specific path and port for your admin-server, you can add this config in application.yml
server:
port: 7700
spring:
boot:
admin:
context-path: /admin-server
application:
name: admin-server
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS

Create a Client Application

  • For our client(microservices) to connect to the admin server, we need to add these dependencies.
  • And we need to add this information to change the configuration of the admin server momentarily. (You will see below Environment Manager)
  • To see version information on admin-server, we need to make sure that configured build plugin.
  • We can add many configs that we need to application.yml
  • we should connect our client to the admin-server with this config in the application.yaml -> spring.boot.admin.client.url
  • management.endpoint means, which info you want to see on admin-server. If you add *, all information will be added on admin-server
management:
endpoints:
web:
exposure:
include: "*"
server:
port: 7701
spring:
application:
name: admin-client
boot:
admin:
client:
url: http://127.0.0.1:7700/admin-server
instance:
service-url: http://127.0.0.1:7701
  • When we run the client app, we will see it on admin-server
  • We can see all configs here,
  • In addition, we can change configs on the admin server by the “Environment Manager”.
  • Also, we can change the log level for a specific class. When we change the log level, we can see the logs instantly without restarting the microservice.
  • We can see how many instances are working which version numbers

more information: https://codecentric.github.io/spring-boot-admin/

Github: admin-server

--

--

--

Java Developer @XPoint-Tech

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Handle Cache-Related Errors in Spring Boot

Laptop on the ground

To own, or not to own

#1 Mobile Application Development Company In New Jersey

Game of Tic-Tac-Toe with Python

InsureDao Testnet

7 Most Popular App Development Tools and Libraries to Know In 2021

Why Your Business Needs Edge Computing

A Gentle Introduction to AWS SageMaker - Part I

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hasan Kadir Demircan

Hasan Kadir Demircan

Java Developer @XPoint-Tech

More from Medium

Microservices communication with Spring WebFlux

Spring Boot: Configure multiple databases

Spring Cloud Gateway — Securing Services with API Key

Creating a Spring boot microservice template