Spring Boot Actuator Health Checks, Metrics & Monitoring

Modern applications need to be observable, monitorable, and resilient. That’s where Spring Boot Actuator shines β€” it exposes production-ready features like health checks, metrics, auditing, info endpoints, and more.

In this guide, we’ll explore how to configure and use Spring Boot Actuator Health Checks, Metrics, and Monitoring endpoints in a typical application.

Spring Boot Actuator Health Checks, Metrics & Monitoring

πŸ“¦ What is Spring Boot Actuator?

Spring Boot Actuator is a subproject that adds a set of REST endpoints to your application to help you monitor and manage it in production.

With a simple dependency, you gain access to:

  • /actuator/health – check if your app is alive
  • /actuator/metrics – runtime metrics
  • /actuator/env, /actuator/info, and more

🧰 Step 1: Add Actuator to Your Project

βœ… Maven Dependency

βš™οΈ Step 2: Basic Configuration

πŸ“ application.yml

You can choose to expose only specific endpoints or all (include: '*' for development).

🌑️ Health Checks

πŸš‘ Endpoint: /actuator/health

The health endpoint reports whether the application is healthy. It integrates with:

  • DB
  • Disk space
  • Redis
  • RabbitMQ
  • Custom checks

Example Output:

βœ… Add DB Health Indicator

If using a datasource, Spring Boot will auto-configure a DataSourceHealthIndicator.

You can also create your own:

πŸ“Š Metrics Endpoint

πŸ“ˆ Endpoint: /actuator/metrics

Gives runtime statistics like:

  • JVM memory usage
  • CPU
  • HTTP request counts and timing
  • Garbage collection
  • Thread states

To view metric names:

To get details of one:

Sample Output:

πŸ–₯️ Info Endpoint

🧾 /actuator/info

Enrich this with build or environment data.

Example:

πŸ“¦ Step 3: Integrate with Prometheus & Grafana

Add Micrometer Prometheus:

Enable /actuator/prometheus

Prometheus Setup

Add this scrape config in your prometheus.yml:

Now you can visualize metrics in Grafana using Prometheus as data source.

πŸ›‘οΈ Securing Actuator Endpoints

By default, most endpoints are secure. Use Spring Security to restrict access.

πŸ§ͺ Bonus: Enable HTTP Trace

Access /actuator/httptrace to see incoming HTTP requests for diagnostics.

βœ… Summary

  • Spring Boot Actuator Health Checks are key to reliable applications.
  • Use /actuator/health, /actuator/metrics, /actuator/info, and /actuator/prometheus for complete monitoring.
  • Integrate with Prometheus & Grafana for visualization.
  • Use custom health indicators for app-specific checks.

πŸ”— References