Backend Development 8 min read

Unlock Spring Boot Actuator: All Endpoints, Configurations, and Code Samples

Spring Boot Actuator provides extensive monitoring and management features via HTTP and JMX; this guide shows how to enable it, lists each endpoint such as /auditevents, /beans, /caches, /conditions, /env, /health, and demonstrates configuration, custom endpoints, and code examples for full utilization.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Unlock Spring Boot Actuator: All Endpoints, Configurations, and Code Samples

Spring Boot provides many additional features for monitoring and managing applications, accessible via HTTP or JMX.

Enable it by adding the

spring-boot-starter-actuator

dependency to your

pom.xml

:

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

/auditevents

Shows audit event information of the current application. Requires an

AuditEventRepository

bean.

/beans

Displays all beans in the Spring application context.

/caches

Lists cache managers and caches. Example response:

<code>{
  "cacheManagers": {
    "cacheManager": {
      "caches": {
        "cache_storage": {
          "target": "org.springframework.data.redis.cache.DefaultRedisCacheWriter"
        }
      }
    }
  }
}
</code>

GET

/caches/cache_storage

returns details of a specific cache manager; DELETE clears its contents.

/conditions

Shows which configuration classes and auto‑configuration classes were applied and why some were not. Example:

<code>@Configuration
@ConditionalOnProperty(prefix = "pack", name = "enable", havingValue = "true")
public class CondiationConfig {
}
</code>

/configprops

Displays properties bound to configuration beans. Example bean:

<code>@Component
@ConfigurationProperties(prefix = "pack")
public class PackConfigProps {
  private String url;
  private Integer port;
}
</code>

Corresponding YAML:

<code>pack:
  url: http://localhost
</code>

Only the configured properties appear in the endpoint output.

/env

Exposes all environment variables; specific variables can be queried via

/env/{name}

.

/health

Shows application health status. Custom health indicators can add details, e.g.:

<code>@Component
public class CustomHealthIndicator implements HealthIndicator {
    @Override
    public Health health() {
        Map<String, Object> details = new HashMap<>();
        details.put("code", "0");
        details.put("message", "成功");
        return Health.up().withDetails(details).build();
    }
}
</code>

Enable detail display with:

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

/httptrace

Shows the last 100 HTTP request/response exchanges. Requires an

HttpTraceRepository

bean, e.g.:

<code>@Configuration
public class HttptraceConfig {
    @Bean
    public HttpTraceRepository httpTraceRepository() {
        return new InMemoryHttpTraceRepository();
    }
}
</code>

After invoking a web endpoint,

/httptrace

returns trace details.

/info

Exposes information defined under the

info

prefix in configuration files.

<code>info:
  author: xg
  time: 2020-11-30
</code>

Access via

/info

returns the JSON above.

/loggers

View or modify logger configuration.

/metrics

Lists all available metrics; individual metric values can be retrieved, e.g.

/metrics/jvm.memory.max

.

/mappings

Shows all

@RequestMapping

paths.

/scheduledtasks

Displays scheduled tasks. Example task that runs every 5 seconds:

<code>@Configuration
@EnableScheduling
public class ScheduleConfig {
    @Scheduled(cron = "0/5 * * * * ?")
    public void task() {
        System.out.println("执行任务...");
    }
}
</code>

/threaddump

Provides a thread dump of the current application.

/shutdown

Shuts down the application (POST). Must be enabled in configuration:

<code>management:
  endpoint:
    shutdown:
      enabled: true
</code>

Additional web endpoints

/logfile – returns log file content (requires

logging.file.name

or

logging.file.path

).

/heapdump – returns an HPROF heap dump.

/jolokia – exposes JMX beans over HTTP when

jolokia-core

is on the classpath.

/prometheus – exposes metrics for Prometheus when

micrometer-registry-prometheus

is present.

Endpoint exposure can be controlled with properties such as

management.endpoints.web.exposure.include

and

management.endpoints.web.exposure.exclude

. Use “*” to enable all endpoints.

Custom endpoints

Custom endpoints can be created with

@Endpoint

(supports JMX and HTTP) or

@WebEndpoint

(HTTP only). Example:

<code>@Endpoint(id = "custom")
@Component
public class CustomEndpoint {
    @ReadOperation
    public Map<String, Object> info() {
        Map<String, Object> res = new HashMap<>();
        res.put("code", 0);
        return res;
    }
}
</code>

Access the custom endpoint at

/actuator/custom

.

Actuator server customization

Actuator server port and base path can be customized:

<code>management:
  server:
    port: 8888
  endpoints:
    web:
      basePath: /pack
</code>
backendJavamonitoringSpring BootActuatorEndpoints
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.