SkillByAIOpen interactive version →

Lesson 17 / 25

Actuator Health and Metrics

Production endpoints.

Health, readiness and liveness

Spring Boot Actuator adds operational endpoints: /actuator/health (aggregating checks such as database connectivity and disk space), liveness and readiness groups for Kubernetes probes, /actuator/metrics and /actuator/prometheus (with Micrometer), info, and more. Expose only what you need over HTTP (management.endpoints.web.exposure.include), protect sensitive endpoints, and consider a separate management port.

Health, profiles, packaging

Actuator exposes health and metrics; profiles and external configuration adapt one build to every environment.

Figure 6.1 — Actuator, profiles and packaging.

Health with the database check, run

I packaged the demo with mvn package, started it with java -jar on port 8085 and called it with curl; the output is copied from that run. The health endpoint reports UP overall, the H2 database check is UP, and the readiness state is UP. Output reduced to three fields with jq.

curl -s localhost:8085/actuator/health | jq -c '{status, db: .components.db.status, readiness: .components.readinessState.status}'

Output:

{"status":"UP","db":"UP","readiness":"UP"}

Use readiness and liveness groups for probes

Point Kubernetes readiness probes at /actuator/health/readiness and liveness probes at /actuator/health/liveness.

Quick check: What does the db component in /actuator/health check?

  • User passwords
  • Disk encryption
  • That the application can reach its database
  • Network bandwidth
Answer

That the application can reach its database — Health aggregates dependency checks.