← All articles
Backend1 min read

Observability with Spring Boot Actuator

You can't operate what you can't see. Actuator exposes health, metrics, and runtime internals through production-ready endpoints with minimal setup.

S

Swapnika Voora

Author

Actuator turns your application into something operators and dashboards can inspect. It ships health checks, metrics, environment details, and more behind a consistent set of HTTP endpoints.

Expose what you need

By default only /health is exposed over HTTP. Opt in to the endpoints you want explicitly — never expose everything in production.

application.properties
management.endpoints.web.exposure.include=health,info,metrics,prometheus
management.endpoint.health.show-details=when_authorized
management.metrics.tags.application=orders-service

Custom health indicators

Add domain-specific checks so /health reflects real dependencies, not just the process being alive.

QueueHealthIndicator.java
@Component
public class QueueHealthIndicator implements HealthIndicator {
 
    @Override
    public Health health() {
        int depth = queue.pendingCount();
        return depth < 1000
            ? Health.up().withDetail("depth", depth).build()
            : Health.down().withDetail("depth", depth).build();
    }
}

Metrics with Micrometer

Micrometer is Actuator's metrics facade. Register counters and timers, and they flow to Prometheus, Datadog, or whatever backend you configure.

OrderMetrics.java
@Service
public class OrderMetrics {
 
    private final Counter placed;
 
    public OrderMetrics(MeterRegistry registry) {
        this.placed = registry.counter("orders.placed");
    }
 
    public void recordPlaced() {
        placed.increment();
    }
}

Takeaways

  • Expose only the endpoints you actually need, and secure them.
  • Write custom health indicators for critical dependencies.
  • Use Micrometer counters and timers to make business events measurable.

Pair Actuator with a Prometheus scrape and a Grafana dashboard, and you get real-time visibility for almost no code.

#java#spring-boot#observability#metrics

More in Backend