To help us visualize the metrics better, we will use a great open source project, spring-boot-admin, located at https://github.com/codecentric/spring-boot-admin. It provides a simple web UI on top of the Spring Boot Actuators to give a nicer view of the various data.
We will create a simple admin application in Gradle using the instructions from https://github.com/codecentric/spring-boot-admin#server-application by performing the following simple steps:
- Go to start.spring.io and create a new application template with the following fields:
- Generate a: Gradle Project
- With: Java
- Spring Boot: 2.0.0 (SNAPSHOT)
- Group: org.sample.admin
- Artifact: spring-boot-admin-web
- Name: Spring Boot Admin Web
- Description: Spring Boot Admin Web Application
- Package Name: org.sample.admin
- Packaging: Jar
- Java Version: 8
- Select the Actuator option under Search for dependencies
- Click on Generate Project alt + to download the application template archive
- Extract the contents from the directory of your choice
- In the extracted directory, execute the gradle wrapper command line to generate a gradlew script
- In the build.gradle file, add the following dependencies to the dependencies block:
compile("de.codecentric:spring-boot-admin-server:2.0.0-SNAPSHOT") compile("de.codecentric:spring-boot-admin-server-ui:2.0.0-SNAPSHOT ")
- We also need to update the repositories block with a reference to use the snapshots repository (as the time of writing, the SBA is not yet released):
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
- Open the SpringBootAdminWebApplication.java file located in the src/main/java/spring-boot-admin-web directory and add the following annotations to the SpringBootAdminWebApplication class:
@SpringBootApplication @EnableAdminServer public class SpringBootAdminWebApplication { public static void main(String[] args) { SpringApplication.run( SpringBootAdminWebApplication.class,
args); } }
- Open the application.properties file located in the src/main/resources directory and add the following settings:
server.port: 8090 spring.application.name: Spring Boot Admin Web spring.cloud.config.enabled: false spring.jackson.serialization.indent_output: true
- We are now ready to start our Admin Web Console by running ./gradlew bootRun and open the browser to http://localhost:8090 to see the following output: