Backend Development 6 min read

Unlock Spring Boot Actuator: Monitor, Health Checks, and Custom Info

This guide walks through configuring Spring Boot Actuator to expose health, environment, and custom application information, covering dependency setup, endpoint exposure, health grouping, multi‑datasource monitoring, and custom InfoContributor implementation for comprehensive runtime insight.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Unlock Spring Boot Actuator: Monitor, Health Checks, and Custom Info

1. Introduction

In Spring Boot, obtaining runtime status and information is essential for monitoring, debugging, and performance tuning. Spring Boot Actuator provides built‑in endpoints such as /actuator/health and /actuator/info to expose health, OS, Java version, build, environment variables, Git info, and more.

2. Practical Example

2.1 Prepare Environment

Add the actuator starter dependency:

<code>&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
&lt;/dependency&gt;
</code>

Configure the management endpoints to expose all paths under a custom base path:

<code>management:
  endpoints:
    web:
      base-path: /ac
      exposure:
        include: '*'
</code>

Now the actuator context path is /ac and all endpoints are visible.

2.2 Application Health

Access /ac/health to see the default health output. To show detailed information, enable it:

<code>management:
  endpoint:
    health:
      show-details: always
</code>

Be aware of security implications; restrict access with authentication.

Additional health indicators such as database and Redis can be enabled:

<code>management:
  health:
    db:
      enabled: true
    redis:
      enabled: true
</code>

Grouped health checks can be defined, e.g., a group named pack that includes only db and redis:

<code>management:
  endpoint:
    health:
      group:
        pack:
          include:
          - db
          - redis
</code>

Access /ac/health/pack to view the group.

2.3 Multi‑DataSource Health

If the project uses a routing data source, Actuator can monitor each source without extra configuration. To ignore routing data sources:

<code>management:
  health:
    db:
      ignore-routing-data-sources: true
</code>

3. Application Info

Info endpoints aggregate data from all InfoContributor beans. Enable the desired sections:

<code>management:
  info:
    env:
      enabled: true
    java:
      enabled: true
    build:
      enabled: true
    git:
      enabled: true
    os:
      enabled: true
</code>

Custom info can be added via configuration:

<code>info:
  pack:
    title: xxxooo Project
    version: 1.0.0
    author: pack
</code>

Or by implementing a custom InfoContributor :

<code>@Component
public class PackInfoContributor implements InfoContributor {
    @Override
    public void contribute(Builder builder) {
        builder.withDetails(Map.of("k1", "v1", "k2", "v2"));
    }
}
</code>
JavaconfigurationSpring BootActuatorHealth Monitoring
Spring Full-Stack Practical Cases
Written by

Spring Full-Stack Practical Cases

Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.

0 followers
Reader feedback

How this landed with the community

login 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.