Careeroza
Actuator Endpoints
Adding Actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>Actuator adds ready-made endpoints under /actuator that tell you whether the app is healthy and what it is doing. Only health is exposed over HTTP by default.
| Endpoint | Shows |
|---|---|
/actuator/health | UP/DOWN, plus database, disk, Redis checks |
/actuator/info | app version, git commit, build time |
/actuator/metrics | JVM memory, CPU, HTTP request timings, pool usage |
/actuator/prometheus | all metrics in Prometheus format |
/actuator/loggers | view and change log levels at runtime |
/actuator/env, /configprops | configuration (values are masked) |
/actuator/threaddump, /heapdump | debugging stuck or leaking apps |
Configuring Exposure
Example
application.yml
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus,loggers
endpoint:
health:
show-details: when-authorized
probes:
enabled: true # /actuator/health/liveness and /readiness
info:
git:
mode: simple
server:
port: 8081 # keep actuator off the public portExample
curl -s localhost:8081/actuator/healthExample output
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"isValid()"}},"diskSpace":{"status":"UP"},"livenessState":{"status":"UP"},"ping":{"status":"UP"},"readinessState":{"status":"UP"},"redis":{"status":"UP","details":{"version":"7.2.4"}}}}Note: Never expose env, heapdump or shutdown publicly. Run actuator on a separate management port, or protect it with Spring Security (role ACTUATOR).
Changing Log Level Without Restart
Example
curl -X POST localhost:8081/actuator/loggers/com.shopease.payment \
-H "Content-Type: application/json" -d '{"configuredLevel":"DEBUG"}'
curl -s localhost:8081/actuator/loggers/com.shopease.paymentExample output
HTTP/1.1 204 No Content
{"configuredLevel":"DEBUG","effectiveLevel":"DEBUG"}