Master Spring Boot Actuator: Monitoring, Metrics, and Management Endpoints

This guide explains how to add Spring Boot Actuator to a project, configure security, enable and customize monitoring endpoints, and use the built‑in REST APIs such as health, info, beans, metrics, and shutdown for production‑grade application observability.

Senior Brother's Insights
Senior Brother's Insights
Senior Brother's Insights
Master Spring Boot Actuator: Monitoring, Metrics, and Management Endpoints

Actuator Overview

In production systems you often need to monitor runtime metrics such as CPU, I/O, disk usage, database health, and custom business indicators. Spring Boot Actuator provides a set of HTTP endpoints that expose internal state information, health checks, metrics, and management operations.

Adding Actuator to a Spring Boot Project

Include the starter dependency:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Actuator brings in two additional modules: spring-boot-actuator (functionality) and spring-boot-actuator-autoconfigure (auto‑configuration).

For security, add spring-boot-starter-security and configure a username/password in application.yml (e.g., admin/admin). The tutorial disables security for simplicity.

Accessing Actuator Endpoints

After starting the application, the base URL http://localhost:8080/actuator returns a JSON document with links to all enabled endpoints, for example:

{
  "_links": {
    "self": {"href": "http://localhost:8080/actuator","templated": false},
    "health": {"href": "http://localhost:8080/actuator/health","templated": false},
    "info": {"href": "http://localhost:8080/actuator/info","templated": false}
  }
}

Common default endpoints include:

/actuator

/actuator/health

/actuator/info

/actuator/metrics

/actuator/beans

/actuator/env

/actuator/configprops

/actuator/mappings

/actuator/conditions

/actuator/heapdump

/actuator/logfile

/actuator/prometheus

You can enable additional endpoints by configuring management.endpoints.web.exposure.include in application.yml. Setting it to '*' exposes all endpoints; you can also list specific ones (e.g., beans,trace).

CORS Configuration

Cross‑origin requests are disabled by default. Enable them with:

management.endpoints.web.cors.allowed-origins: https://www.example.com
management.endpoints.web.cors.allowed-methods: GET,POST

REST Endpoint Details

Health

The /actuator/health endpoint reports the overall application status (UP, DOWN, etc.) and aggregates health indicators such as database connectivity, disk space, and external services. Example response: {"status":"UP"} You can control the order of status evaluation with setStatusOrder(...) and expose detailed health information by setting management.endpoint.health.show-details=always.

Info

The /actuator/info endpoint returns arbitrary key‑value pairs defined under the info prefix in application.yml or values extracted from the Maven POM using @project placeholders.

info:
  app:
    name: spring-boot-actuator
    version: 1.0.0

Beans

/actuator/beans

lists all Spring beans in the application context, showing bean name, scope, type, resource location, and dependencies.

{
  "contexts": {
    "application": {
      "beans": {
        "endpointCachingOperationInvokerAdvisor": {
          "scope": "singleton",
          "type": "org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor",
          "resource": "class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.class]",
          "dependencies": ["environment"]
        }
      }
    }
  }
}

Config Props

/actuator/configprops

provides a report of all @ConfigurationProperties beans and their bound values.

{
  "spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties": {
    "prefix": "spring.transaction",
    "properties": {}
  }
}

Environment

/actuator/env

returns all environment properties, including system variables, JVM properties, and command‑line arguments.

Metrics

/actuator/metrics

lists available metric names (e.g., jvm.memory.used, http.server.requests, process.cpu.usage) and can be queried for a specific metric value.

{
  "names": ["jvm.memory.max","jvm.threads.states","http.server.requests",...]
}

Key metric groups include system information, memory (heap, non‑heap), threads, classes, garbage collection, HTTP sessions, gauges, and counters.

Thread Dump

/actuator/threaddump

returns a snapshot of all live threads, their states, stack traces, and lock information, useful for debugging concurrency issues.

{
  "threads": [{
    "threadName": "Reference Handler",
    "threadId": 2,
    "threadState": "RUNNABLE",
    "stackTrace": [{...}]
  }, ...]
}

Shutdown

Enable graceful shutdown with management.endpoint.shutdown.enabled=true. Trigger it via a POST request: curl -X POST "http://localhost:8080/actuator/shutdown" Response:

{"message":"Shutting down, bye..."}

Native Endpoint Categories

Application configuration endpoints (e.g., /conditions, /info) provide static reports about auto‑configuration and custom info.

Metrics endpoints (e.g., /metrics, /heapdump) deliver dynamic runtime snapshots such as memory usage and request statistics.

Operational control endpoints (e.g., /shutdown) allow actions like terminating the application.

Conclusion

The article covers the essential features of Spring Boot Actuator, showing how to add the dependency, secure the endpoints, expose additional endpoints, configure CORS, and use the most common REST endpoints for health checks, application info, bean inspection, configuration properties, environment details, metrics, thread dumps, and graceful shutdown.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

metricshealthspring-boot
Senior Brother's Insights
Written by

Senior Brother's Insights

A public account focused on workplace, career growth, team management, and self-improvement. The author is the writer of books including 'SpringBoot Technology Insider' and 'Drools 8 Rule Engine: Core Technology and Practice'.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.