The previous sections explored most of the Spring Boot features required to develop a microservice. In this section, some of the production-ready operational aspects of Spring Boot will be explored.
Spring Boot actuators provide an excellent out-of-the-box mechanism to monitor and manage Spring Boot applications in production:
chapter2.bootactuator
. This time, select Web and Actuators under Ops. Similar to the chapter2.bootrest
project, add a GreeterController
endpoint with the greet
method.localhost:8080/actuator
. This will open the HAL browser. Then, review the Links section.A number of links are available under the Links section. These are automatically exposed by the Spring Boot actuator:
Some of the important links are listed as follows:
dump
: This performs a thread dump and displays the resultmappings
: This lists all the HTTP request mappingsinfo
: This displays information about the applicationhealth
: This displays the application's health conditionsautoconfig
: This displays the autoconfiguration reportmetrics
: This shows different metrics collected from the applicationAlternately, we can use the JMX console to see the Spring Boot information. Connect to the remote Spring Boot instance from JConsole. The Boot information will be shown as follows:
Spring Boot provides remote access to the Boot application using SSH. The following command connects to the Spring Boot application from a terminal window:
$ ssh -p 2000 user@localhost
The password can be customized by adding the shell.auth.simple.user.password
property in the application.properties
file. The updated application.properties
file will look similar to the following:
shell.auth.simple.user.password=admin
When connected with the preceding command, similar actuator information can be accessed. Here is an example of the metrics information accessed through the CLI:
help
: This lists out all the options availabledashboard
: This is one interesting feature that shows a lot of system-level information