Spring Boot Actuator: Seamlessly Monitor your Applications

Spring Boot Actuator: Seamlessly Monitor your Applications

Introduction

Spring Boot Actuator helps to monitor and manage your application in production. It provides a number of endpoints to gain insights into application's health, metrics, list of beans, request mappings and other information.

How to use Actuator ?

  1. Add the actuator dependency in pom.xml as follows:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  1. Start the Application Server and hit the url localhost:8080/actuator.

Output

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost:8080/actuator/health/{*path}",
      "templated": true
    },
    "health": {
      "href": "http://localhost:8080/actuator/health",
      "templated": false
    }
  }
}
{
  "status": "UP"
}
  • By default, only health endpoint is exposed. To utilize more features provided by actuator, they need to be enabled in "application.properties" file.
#expose all endpoints
management.endpoints.web.exposure.include=*

#expose specific endpoints
#management.endpoints.web.exposure.include=health,info,metrics,env

Output

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    "beans": {
      "href": "http://localhost:8080/actuator/beans",
      "templated": false
    },
    "caches-cache": {
      "href": "http://localhost:8080/actuator/caches/{cache}",
      "templated": true
    },
    "caches": {
      "href": "http://localhost:8080/actuator/caches",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost:8080/actuator/health/{*path}",
      "templated": true
    },
    "health": {
      "href": "http://localhost:8080/actuator/health",
      "templated": false
    },
    "info": {
      "href": "http://localhost:8080/actuator/info",
      "templated": false
    },
    "conditions": {
      "href": "http://localhost:8080/actuator/conditions",
      "templated": false
    },
    "configprops": {
      "href": "http://localhost:8080/actuator/configprops",
      "templated": false
    },
    "configprops-prefix": {
      "href": "http://localhost:8080/actuator/configprops/{prefix}",
      "templated": true
    },
    "env": {
      "href": "http://localhost:8080/actuator/env",
      "templated": false
    },
    "env-toMatch": {
      "href": "http://localhost:8080/actuator/env/{toMatch}",
      "templated": true
    },
    "loggers": {
      "href": "http://localhost:8080/actuator/loggers",
      "templated": false
    },
    "loggers-name": {
      "href": "http://localhost:8080/actuator/loggers/{name}",
      "templated": true
    },
    "heapdump": {
      "href": "http://localhost:8080/actuator/heapdump",
      "templated": false
    },
    "threaddump": {
      "href": "http://localhost:8080/actuator/threaddump",
      "templated": false
    },
    "metrics-requiredMetricName": {
      "href": "http://localhost:8080/actuator/metrics/{requiredMetricName}",
      "templated": true
    },
    "metrics": {
      "href": "http://localhost:8080/actuator/metrics",
      "templated": false
    },
    "sbom": {
      "href": "http://localhost:8080/actuator/sbom",
      "templated": false
    },
    "sbom-id": {
      "href": "http://localhost:8080/actuator/sbom/{id}",
      "templated": true
    },
    "scheduledtasks": {
      "href": "http://localhost:8080/actuator/scheduledtasks",
      "templated": false
    },
    "mappings": {
      "href": "http://localhost:8080/actuator/mappings",
      "templated": false
    }
  }
}
  • Common endpoints of Spring Boot Actuator
EndpointDetails
/actuator/healthDisplays application's health information.
/actuator/beansDisplays a list of beans present in application context.
/actuator/metricsDisplays application metrics.
/actuator/envProvides access to environment properties such as port.
/actuator/loggersDisplays and configures log level of the application.

Summary

Spring Boot Actuator is a tool for monitoring and managing applications in production. To use it, add the `spring-boot-starter-actuator` dependency to your project. Access the Actuator endpoints via `localhost:8080/actuator` to monitor health, metrics, beans, and other details. Initially, only the health endpoint is exposed, but more endpoints can be enabled through configuration in the `application.properties` file. Key endpoints include `/actuator/health`, `/actuator/beans`, `/actuator/metrics`, `/actuator/env`, and `/actuator/loggers`.