Mastering Spring Boot Actuator: A Complete Guide to All Native Endpoints

This article provides a thorough walkthrough of Spring Boot Actuator's native endpoints, explaining their purpose, configuration, and usage with practical code examples and screenshots, enabling developers to monitor, diagnose, and manage Spring Boot microservices effectively.

Senior Brother's Insights
Senior Brother's Insights
Senior Brother's Insights
Mastering Spring Boot Actuator: A Complete Guide to All Native Endpoints

Introduction

In micro‑service architectures built on Spring Cloud or Spring Boot, monitoring is essential. Spring Boot Actuator offers a comprehensive, easy‑to‑use set of endpoints for exposing application health, metrics, configuration, and control functions.

Endpoints Overview

Actuator endpoints (or "Endpoints") allow external tools to interact with a running application. Typical examples include /health for health status and /metrics for JVM and system metrics. Native endpoints are grouped into three categories: application configuration, metric collection, and operational control.

Actuator Base Endpoint

Accessing http://localhost:8080/actuator returns a JSON list of all enabled endpoints. The response can be beautified with a JSON viewer.

Actuator endpoint list
Actuator endpoint list

auditevents Endpoint

The /auditevents endpoint records authentication and authorization events, but it is only active when an AuditEventRepository bean exists.

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

Security configuration is required to expose the events:

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

   @Override
   protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.inMemoryAuthentication()
            .withUser("admin")
            .password(bcryptPasswordEncoder().encode("admin"))
            .roles("admin");
   }

   @Bean
   public PasswordEncoder bcryptPasswordEncoder() {
      return new BCryptPasswordEncoder();
   }
}

An in‑memory audit repository is also defined:

@Configuration
public class AuditEventConfig {

   @Bean
   public InMemoryAuditEventRepository repository(){
      return new InMemoryAuditEventRepository();
   }
}

After restarting, visiting http://localhost:8080/actuator/auditevents shows authentication failures and successes, including timestamps, usernames, event types, and session IDs.

Auditevents result
Auditevents result

beans Endpoint

/beans

lists every bean in the Spring context, showing name, type, scope, and dependencies. It is useful for verifying bean creation.

Beans endpoint
Beans endpoint

caches and caches‑cache Endpoints

To demonstrate cache exposure, the project adds spring-boot-starter-cache and enables caching with @EnableCaching. A simple controller returns a map and is annotated with @Cacheable("queryAll").

@RestController
public class CacheController {

    @RequestMapping("/queryAll")
    @Cacheable(value = "queryAll")
    public Map<String, String> queryAll() {
        Map<String, String> map = new HashMap<>();
        map.put("1", "Tom");
        map.put("2", "Steven");
        return map;
    }
}

Before the first request, /actuator/caches shows an empty cache. After calling /queryAll, the cache entry appears, and /actuator/caches/queryAll displays its key, type, and stored data.

Cache content
Cache content

health Endpoint

/health

reports the overall status (UP/DOWN) and, when configured, detailed component health. Adding a MySQL datasource and setting management.endpoint.health.show-details=always reveals database, disk, and ping health.

spring:
  datasource:
    url: jdbc:mysql://xxx:3333/xxx?characterEncoding=utf8&serverTimezone=Asia/Shanghai
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver
Health details (UP)
Health details (UP)

When the DB credentials are wrong, the health endpoint returns DOWN with an error description.

Health details (DOWN)
Health details (DOWN)

info Endpoint

/info

exposes custom properties prefixed with info. Adding the following to application.yml:

info:
  user:
    type: 公众号
    name: 程序新视界
    wechat: zhuan2quan

Results are visible at /actuator/info.

Info endpoint
Info endpoint

conditions Endpoint

/conditions

helps debug why a particular auto‑configuration class was applied or not, showing matched conditions and messages.

Conditions endpoint
Conditions endpoint

shutdown Endpoint

Enabled via management.endpoint.shutdown.enabled=true, /shutdown accepts a POST request to gracefully stop the application.

curl -X POST "http://localhost:8080/actuator/shutdown"
{
    "message": "Shutting down, bye..."
}

configprops Endpoint

/configprops

lists all beans annotated with @ConfigurationProperties. For the custom InfoProperties class:

@Component
@ConfigurationProperties(prefix = "info")
public class InfoProperties {
    private String type;
    private String name;
    private String wechat;
    // getters and setters omitted
}
Configprops endpoint
Configprops endpoint

env and env‑toMatch Endpoints

/env

returns all environment properties, while /env/{key} fetches a specific property, e.g., /env/info.user.name.

env‑toMatch result
env‑toMatch result

loggers and loggers‑name Endpoints

/loggers

lists all logger configurations; /loggers/{name} shows the effective level for a specific logger, such as the application’s main class.

Loggers list
Loggers list
{
    "configuredLevel": null,
    "effectiveLevel": "INFO"
}

heapdump Endpoint

/heapdump

returns a JVM heap dump file (binary .hprof) that can be opened with VisualVM for memory analysis.

Heapdump analysis
Heapdump analysis

threaddump Endpoint

/threaddump

provides a snapshot of all live threads, useful for diagnosing deadlocks or thread‑pool exhaustion.

Thread dump
Thread dump

metrics and metrics‑{name} Endpoints

/metrics

lists available metric names. Individual metric details are retrieved via /metrics/{name}, e.g., /metrics/jvm.memory.max shows maximum heap size.

{
    "names": ["jvm.memory.max", "jvm.threads.states", ...]
}
{
    "name": "jvm.memory.max",
    "description": "The maximum amount of memory in bytes that can be used for memory management",
    "baseUnit": "bytes",
    "measurements": [{"statistic": "VALUE", "value": 5606211583}],
    "availableTags": [{"tag": "area", "values": ["heap", "nonheap"]}, {"tag": "id", "values": ["Compressed Class Space", "PS Survivor Space", "PS Old Gen", "Metaspace", "PS Eden Space", "Code Cache"]}]
}

scheduledtasks Endpoint

After enabling scheduling with @EnableScheduling, two tasks are defined—one using a cron expression and another using a fixed delay. /scheduledtasks lists them with their execution patterns.

@Component
public class MyTask {

    @Scheduled(cron = "0/10 * * * * *")
    public void work() {
        System.out.println("I am a cron job.");
    }

    @Scheduled(fixedDelay = 10000)
    public void work1() {
        System.out.println("I am a fixedDelay job.");
    }
}
Scheduled tasks
Scheduled tasks

mappings Endpoint

/mappings

displays all URL‑to‑controller mappings, helping developers locate which controller method handles a given request.

Mappings overview
Mappings overview

Conclusion

The article demonstrates each native Actuator endpoint with concrete code and visual results, showing how Actuator can dramatically simplify runtime inspection, health checking, metric collection, and operational control for Spring Boot microservices.

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.

JavamonitoringMicroservicesSpring BootActuatorEndpoints
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.