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
- 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
- then, when we call http://localhost:7700/admin-server, browser will return an empty admin server page like below
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
- 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/