Actuator and safe operations
What you will learn
Actuator adds operational endpoints, not an automatic production security perimeter. A health endpoint reports selected health indicators. Expose only the information required by operators and separate network reachability from authentication.
- Distinguish endpoint availability, exposure and authorization.
- Design minimal health output and safe logging.
- Explain the local verification plan and its deployment limits.
Plain Java examples: save as Main.java in a fresh directory, then run javac --release 21 Main.java and java Main. Boot examples require the separate pinned companion Maven project. Their predicted results are not execution evidence.
Separate health status from internal details
public class Main { record Health(boolean ready, String internalReason) { String publicStatus() { return ready ? "UP" : "DOWN"; } } public static void main(String[] args) { System.out.println(new Health(true, "internal-ok").publicStatus()); System.out.println(new Health(false, "internal-timeout").publicStatus()); }}Expected output:
UPDOWNThe public status omits internal diagnostic reasons. This is a DTO model, not an Actuator response.
A narrow operational surface
Actuator endpoints have access settings and exposure controls. An endpoint must be permitted and exposed for HTTP availability; exposure does not authenticate callers. This project explicitly includes health only, sets show-details and show-components to never, disables JMX registration with spring.jmx.enabled=false and listens on 127.0.0.1. With the default base path, health is /actuator/health. /actuator/env is not exposed. A custom management address requires a separate management port; if used, bind and protect both servers. Loopback alone does not defend against other local processes or SSRF.
What health means
A simple health status UP indicates that the registered checks are currently reporting success, not that every user flow works. DOWN and OUT_OF_SERVICE normally map to HTTP 503; mappings can be customized. Liveness asks whether a process should be restarted; readiness asks whether it should receive traffic. Do not put an unreliable external service in liveness by default or restart storms may follow. Select readiness dependencies by failure policy. Expose limited data, avoid environment/config/heap dumps, and apply authentication/authorization in deployment.
Logs and deployment
Use parameterized logs, log levels and bounded output; do not log credentials or request bodies by default. Metrics, traces and logging provide different signals. The sample /ping endpoint is a minimal local smoke check; HTTP controllers and structured errors will be developed next chapter. Verify a specific known process and its binding, request timeout, status and response; stop it afterward. The application is not deployed, and no Spring Security policy is demonstrated here.
Separate exposure and authorization
import java.util.Set;public class Main { static boolean allowed(Set<String> exposed, String id, boolean authorized) { return exposed.contains(id) && authorized; } public static void main(String[] args) { var exposed = Set.of("health"); System.out.println(allowed(exposed,"health",true)); System.out.println(allowed(exposed,"env",true)); System.out.println(allowed(exposed,"health",false)); }}Expected output:
truefalsefalseBoth conditions must hold in this simplified policy. It is not a Spring Security filter chain and makes no claim about default anonymous access.
Minimal HTTP smoke endpoint
Source-reviewed, NOT RUN. File lab-fixtures/boot-v38/src/main/java/example/bootlab/PingController.java; use the companion lab README.
package example.bootlab;
import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;
@RestControllerpublic class PingController { @GetMapping("/ping") public String ping() { return "pong"; }}Predicted behavior: GET /ping returns 200 with body pong; GET /actuator/health returns a minimal health status; /actuator/env is not exposed.
Use the lab README and full configuration. /ping is application logic, not Actuator. No actual Boot server has been started.
Common mistakes
Never set exposure.include=* as a debugging shortcut on a public service. A healthy process can still have a broken business operation. Do not use loopback as a substitute for authorization in a deployed system.
Practice
Create a function taking a health status and an internal diagnostic message. Return only status and a modeled HTTP code: UP -> 200, DOWN -> 503. Print UP:200 and DOWN:503 without disclosing internal reasons.
Expected output:
UP:200DOWN:503Compare with the manual review criteria.
Official reading: Endpoints · Monitoring. Boot execution and independent review remain pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Actuator and safe operations — knowledge check
Spring Boot configuration and operational reasoning.
Does endpoint exposure authenticate a caller?
Which health detail setting minimizes diagnostics?
What is a readiness check for?
Which endpoint is explicitly exposed in this lab?
What is a safe approach to logs?