Spring Boot Actuator tutorial

The Spring Boot Actuator is the one Spring starter that I recommend every developer add to their Gradle build or Maven POM file.

What is the Spring Boot Actuator?

The Spring Boot Actuator is a real-time metrics gathering and analytics engine that reports on the status of your applications at runtime.

Through numerous Actuator endpoints enabled and exposed over HTTP, developers can garner a variety of information about their application's configuration and performance.

Spring Boot Actuator endpoints

Some of the most popular Actuator endpoints include the following:

  • Env. Provides information about how both hardware and software are configured on the server.
  • Health. Reports on readiness and liveness of a Spring Boot application.
  • Loggers. Reports on which logging services are active along with their configured logging level.
  • Configprops. Displays all the objects decorated with the @ConfigurationProperties annotation.
  • Conditions. Shows which components passed the checks required for them to be autoconfigured by Spring.
  • Threaddump. Shows all the active threads along with their blocked status.
  • Heapdump. Creates a file that can be read by a heap dump analysis tool such as Hprof.
  • Stop. One of the few activators disabled by default, this activator when enabled and exposed can be used to terminate an application.

Spring Boot Actuator metrics

Perhaps the most commonly used of all the endpoints is Spring Boot Actuator metrics. This endpoint reports a wide range of information about the running system, such as the following:

  • Memory allocated to garbage collection.
  • JVM memory usage.
  • Idle JDBC connections.
  • Loaded and unloaded Java classes.
  • CPU usage time.
  • Active Tomcat sessions.
  • Active Spring Data connections.

Spring Boot Actuator dashboards

Spring Boot Actuator endpoints garner data and deliver it in JSON format. This makes the data tedious to read in a browser, but also incredibly easy to integrate into a web application. For the latter reason, many organizations build React-based, JavaScript-based or even Spring MVC-based dashboards to capture metrics and report them back to the development team.

Spring Boot Actuator tutorial

This tutorial explores how to use the Spring Boot Actuator, stepping through all the important aspects of the tool, including the following:

  • How to configure the Actuator's Maven dependency.
  • How to expose and enable Actuator endpoints.
  • How to view the Actuator exposed metrics.
  • How to enable the stop endpoint.
  • How to create your own Spring Boot Actuator.

Every application should include the Spring Boot Actuator, as it provides a great deal of insight into how an application performs at runtime. And because every application should include it, every Spring Boot developer should learn about it, which is exactly what this Spring Boot Actuator tutorial is all about.

Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; Spring; and container-based technologies such as Docker, Swarm and Kubernetes.

View All Videos