Spring Boot Admin

While browsing the internet I stumbled upon a nice tool called spring-boot-admin (https://github.com/codecentric/spring-boot-admin). This tool, made by Codecentric, offers a nice overview that gives you access to things like metrics, log levels, environment properties, number of threads and many more that are exposed by the Spring Boot Actuator.

Get started

To get started you’ll need to set up a new application. This application will serve as the admin interface where client applications will register itself. To do this you’ll need to do two things.

First include the following dependency in your pom.xml (or whatever tool you are using)

<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server</artifactId>
    <version>1.5.4</version>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-server-ui</artifactId>
    <version>1.5.4</version>
</dependency>

Second, use the @EnableAdminServerannotation

To setup the client application you just include the following dependency in one of your spring boot projects that you want to be added to the spring-boot-admin interface:

<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>1.5.4</version>
</dependency>

and add the following properties to your application.properties:

spring.boot.admin.url: http://localhost:8080
spring.boot.admin.client.name=My cool app
management.security.enabled: false

This makes sure that the client application registers itself under the given name to the admin application you just created.

Metrics

This tab displays a lot of numbers about your application. One of the nice features is that it shows a counter of all the requests that are made per endpoint. This gives you detailed information about whether or not some endpoints completed their requests successful or unsuccessful. As can be seen in the example below, also our custom defined counters, by using the Spring Metrics CounterService, are included in the interface.

Environment

Sometimes when you’ve deployed a new version of your service it doesn’t behave like you expected. This could be due to application properties that weren’t loaded correctly for example. With spring-boot-admin you can pinpoint the problem in one glance. This tab also shows all the spring profiles that are currently used.

Logging

Now let’s say you are testing one of your applications on a test server. Throughout your application a lot of debug logging is used so the logging won’t show up in the production environments. In the ‘Logging’ tab of spring-boot-admin you can change the log level per class with one click. Now troubleshooting an issue becomes a lot easier. When your done you can set it back to the original log level of course, or even turn it off if your feeling really confident 🙂

Notifications

Another great feature is that you can enable notifications in your web browser. This means that you’ll get a popup whenever an application down. The nice thing about this is that it keeps reminding you every 10 minutes. When your application is up again, it stops. But it doesn’t stop there. It even has build in support for sending emails, Pagerduty and Slack notifications.

Security

In a real world application you would want to make sure that your metrics endpoints are secured. Spring Boot Admin provides support for Basic Authentication. You can set the username and password for the metrics endpoints in a property file. These properties will be send as metadata to the admin server when registering your service. Below is an example of those properties:

spring.boot.admin.client.metadata.user.name=user
spring.boot.admin.client.metadata.user.password=password

Of course spring-boot-admin covers a lot more features, but the best way to find out about is to just do it yourself. There’s a page with detailed documentation which can be found here http://codecentric.github.io/spring-boot-admin/1.5.4/#_notifications .

Leave a Reply

Your email address will not be published. Required fields are marked *