Reputation: 2835
Spring boot admin is a great tool to make the health and metrics of my spring boot application (in my case a web-server) available. I've followed the reference guide and could finally get it to run, with one exception though: The server doesn't seem to recognize if the client crashes/goes down.
For testing I currently use separate applications, both running on the same host. In the final version I plan to have multiple clients (running on separate IP addresses) to register with a single server running on its separate IP).
Server (a separate spring boot project)
pom.xml
...
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
...
application.properties:
server.port=8081
MyMain:
@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class MyMain {
public static void main(String[] args) {
SpringApplication.run(MyMain.class, args);
}
}
Client (my WebApp to be monitored):
pom.xml:
...
<!-- SPRING BOOT ADMIN (CLIENT) -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
...
application.properties:
server.port=8080
spring.boot.admin.url=http://localhost:8081
spring.boot.admin.client.management-url=http://localhost:8081
spring.boot.admin.client.service-url=http://localhost:8080
spring.boot.admin.client.name=my-rest-app
With this setup I can connect to http://localhost:8080 to get my web-app or to http://localhost:8081 to see the admin/monitoring UI. The status shows UP and I can browse the mem/heap/traces/...
The issue now is, that if I kill the web-app the status remains UP.
spring.boot.admin.monitor.period
is checking every 10s the status of the clients app.Upvotes: 0
Views: 1559
Reputation: 936
It's simple.
spring.boot.admin.auto-deregistration=true
Set this in your application.properties.
Keep in mind, this only works when your application is terminated gracefully or using SIGTERM (kill -15 PID
).
In case you kill your application, the app won't deregister itself because the context was not closed properly.
See more here- https://codecentric.github.io/spring-boot-admin/1.4.3/#spring-boot-admin-client
Upvotes: 1
Reputation: 4455
Try running the application through the command line from your project directory -
mvn spring-boot:run
Upvotes: 1