15 Working with Spring Boot Actuator

 

This chapter covers

  • Enabling Actuator in Spring Boot projects
  • Exploring Actuator endpoints
  • Customizing Actuator
  • Securing Actuator

Have you ever tried to guess what’s inside a wrapped gift? You shake it, weigh it, and measure it. And you might even have a solid idea as to what’s inside. But until you open it up, there’s no way of knowing for sure.

A running application is kind of like a wrapped gift. You can poke at it and make reasonable guesses as to what’s going on under the covers. But how can you know for sure? If only there were some way that you could peek inside a running application, see how it’s behaving, check on its health, and maybe even trigger operations that influence how it runs!

In this chapter, we’re going to explore Spring Boot Actuator. Actuator offers production-ready features such as monitoring and metrics to Spring Boot applications. Actuator’s features are provided by way of several endpoints, which are made available over HTTP as well as through JMX MBeans. This chapter focuses primarily on HTTP endpoints, saving JMX endpoints for chapter 18.

15.1 Introducing Actuator

In a machine, an actuator is a component that’s responsible for controlling and moving a mechanism. In a Spring Boot application, the Spring Boot Actuator plays that same role, enabling us to see inside of a running application and, to some degree, control how the application behaves.

15.1.1 Configuring Actuator’s base path

15.1.2 Enabling and disabling Actuator endpoints

15.2 Consuming Actuator endpoints

15.2.1 Fetching essential application information

15.2.2 Viewing configuration details

15.2.3 Viewing application activity

15.2.4 Tapping runtime metrics

15.3 Customizing Actuator

15.3.1 Contributing information to the /info endpoint

15.3.2 Defining custom health indicators

15.3.3 Registering custom metrics