Java and Spring Level 3 This level · 39 of 56
Hard java spring

How does Spring Boot integrate with Actuator internally?

The 30 second answer

Actuator uses auto-configuration to create management endpoints such as health, metrics and info. It discovers endpoint operations, commonly declared with @Endpoint, @ReadOperation and @WriteOperation, then adapts them for HTTP or JMX. Having an endpoint bean isn't enough: access rules must allow it, and it must be exposed through the chosen transport. Only health is exposed over HTTP by default. Its result comes from HealthIndicator beans, including indicators contributed for things like the database.

Could you say this in an interview?

1. Endpoints are beans. A custom endpoint shows the model:

@Component
@Endpoint(id = "featureflags")
class FeatureFlagsEndpoint {
    private final FlagService flags;
    FeatureFlagsEndpoint(FlagService flags) { this.flags = flags; }

    @ReadOperation
    Map<String, Boolean> flags() { return flags.all(); }

    @WriteOperation
    void set(@Selector String name, boolean enabled) { flags.set(name, enabled); }
}

This becomes GET /actuator/featureflags and POST /actuator/featureflags/{name}. The endpoint code does not know about HTTP; Spring Boot builds web and JMX operations from the annotations. Spring Boot's built-in endpoints work the same way.

2. Exposure is a property. Web exposure is bound from management.endpoints.web:

@ConfigurationProperties("management.endpoints.web")
public class WebEndpointProperties {
    private String basePath = "/actuator";
    ...
    public static class Exposure {
        private Set<String> include = new LinkedHashSet<>();

WebEndpointProperties.java L23-L77. The default for include is health, declared in the configuration metadata (additional-spring-configuration-metadata.json L81-L85).

management:
  endpoints:
    web:
      exposure:
        include: health,info,prometheus

3. Health is composed. Other auto-configurations add HealthIndicator beans when their technology is present: database, Redis, disk space, and more. The health endpoint aggregates them into one status. Health groups such as liveness and readiness give Kubernetes probe URLs (/actuator/health/liveness, /actuator/health/readiness); readiness follows the ApplicationAvailability state that SpringApplication publishes during startup.

4. Metrics. Actuator auto-configures Micrometer. Spring MVC requests, JVM memory, HikariCP pools and more are recorded as meters. Adding micrometer-registry-prometheus exposes a prometheus endpoint.

5. Separate port and security. management.server.port runs Actuator on a separate port. If Spring Security is present, Actuator endpoints are secured like other URLs; you write rules with EndpointRequest.

Interview distinction: "enabled/available" and "exposed" are different. An endpoint can exist as a bean but not be reachable over HTTP. Exposing env or heapdump publicly is a security risk.

Alternate interview scenarios

"Actuator reveals a production secret through environment output. How do you stop the exposure safely?"

In current Spring Boot versions the env and configprops endpoints mask values by default, and they only show raw values when management.endpoint.env.show-values is changed from never, so someone opted in or a custom sanitizing setup failed. I first treat the secret as compromised and rotate it, because it has already been visible. Then I set show-values back to never, or to when-authorized with a specific role, remove env from the web exposure list unless it is really needed, put Actuator behind Spring Security or on a separate management port reachable only internally, and confirm with an unauthenticated request that the endpoint is gone. Finally I add a check in configuration review or tests so exposure of env, configprops or heapdump cannot return unnoticed.

Sources (3)
  1. Spring Boot reference: Actuator endpoints (exposing, security, custom endpoints)docs.spring.io
  2. Spring Boot reference: Kubernetes probesdocs.spring.io
  3. Spring Boot reference: Sanitize sensitive values (show-values)docs.spring.io
Previous
Next