Easy java spring

What is Spring Boot Actuator used for?

The 30 second answer

Actuator adds production endpoints to the app: health for load balancers and Kubernetes probes, metrics through Micrometer, info, environment, loggers and more. By default only the health endpoint is exposed over HTTP, so I choose which others to expose and protect them, because env or heapdump can leak sensitive data.

<!-- level: 1 -->

  • Add spring-boot-starter-actuator.
  • Useful endpoints: /actuator/health (with liveness and readiness groups for Kubernetes), /actuator/metrics and /actuator/prometheus (Micrometer), /actuator/info, /actuator/loggers (change log levels at runtime), /actuator/env, /actuator/threaddump, /actuator/heapdump.
  • The Spring Boot reference says that by default only the health endpoint is exposed over HTTP and JMX. Expose more with management.endpoints.web.exposure.include, and protect them with Spring Security or a separate management port.
  • Interview point: health checks should reflect whether the app can serve traffic, and liveness should not depend on the database, or one database blip restarts every pod.
Sources (2)
  1. Spring Boot reference: Actuatordocs.spring.io
  2. Spring Boot reference: Actuator endpointsdocs.spring.io