Warning: Never expose /env publicly — it leaks secrets.
7. Using Loggers Endpoint (/actuator/loggers)
Example: Change log level at runtime via actuator
# GET current levelscurl http://localhost:8080/actuator/loggers/com.example# Change level at runtime (POST)curl -X POST -H "Content-Type: application/json" \ -d '{"configuredLevel":"DEBUG"}' \ http://localhost:8080/actuator/loggers/com.example
8. Using Thread Dump Endpoint
Endpoint
Format
/threaddump
JSON or text/plain (Accept header)
Use
Diagnose deadlocks, stuck threads
9. Using Heap Dump Endpoint
Aspect
Detail
Format
HPROF binary
Analysis
VisualVM, MAT, JProfiler
Performance
Pauses JVM — use with care
10. Using Beans Endpoint
Note: Returns ALL beans in context with their dependencies — useful for
debugging wiring issues.
11. Creating Custom Health Indicators
Example: Custom health indicator with latency detail
@Componentpublic class PaymentGatewayHealth implements HealthIndicator { private final PaymentClient client; public PaymentGatewayHealth(PaymentClient client) { this.client = client; } @Override public Health health() { try { var status = client.ping(); return Health.up().withDetail("latencyMs", status.latency()).build(); } catch (Exception ex) { return Health.down(ex).build(); } }}
12. Creating Custom Metrics (MeterRegistry)
Example: Custom counter and timer metrics
@Servicepublic class OrderService { private final Counter placed; private final Timer processTime; public OrderService(MeterRegistry reg) { this.placed = Counter.builder("orders.placed").tag("region", "us").register(reg); this.processTime = Timer.builder("orders.process").register(reg); } public Order place(NewOrder o) { return processTime.record(() -> { placed.increment(); return repo.save(/*…*/); }); }}