Spring Boot Monitoring with Actuator 5 — Questions and Answers
Question 1: What happens when you annotate a method with @Timed from Micrometer in a Spring Boot application?
- The method execution time is automatically recorded as a Timer metric (Correct answer)
- A gauge is created tracking how many times the method is currently executing
- A log entry is written with the execution duration on each invocation
- An async span is created and sent to a distributed tracing backend
Correct answer: The method execution time is automatically recorded as a Timer metric
@Timed (with AspectJ support enabled) wraps the method invocation and records its duration in a Micrometer Timer.
Question 2: Which property disables a specific Actuator endpoint, for example the shutdown endpoint?
- management.endpoint.shutdown.enabled=false (Correct answer)
- management.endpoints.shutdown.disable=true
- actuator.shutdown.enabled=false
- management.shutdown.endpoint.active=false
Correct answer: management.endpoint.shutdown.enabled=false
Individual endpoints are toggled with management.endpoint.<endpoint-name>.enabled=false.
Question 3: What is the purpose of the /actuator/mappings endpoint?
- Displays all @RequestMapping routes registered in the application along with their handler details (Correct answer)
- Shows the URL-to-bean mappings for dependency injection
- Lists all message queue bindings and their consumer counts
- Exports the sitemap of all publicly accessible pages
Correct answer: Displays all @RequestMapping routes registered in the application along with their handler details
The /actuator/mappings endpoint enumerates every request handler mapping, including path patterns, HTTP methods, and handler classes.
Question 4: How do you secure Actuator endpoints using Spring Security so only users with the ADMIN role can access them?
- Configure a SecurityFilterChain that matches /actuator/** and requires ROLE_ADMIN (Correct answer)
- Set management.endpoints.security.role=ADMIN in properties
- Annotate each endpoint class with @Secured("ROLE_ADMIN")
- Set management.endpoint.default.roles=ADMIN globally
Correct answer: Configure a SecurityFilterChain that matches /actuator/** and requires ROLE_ADMIN
Defining a SecurityFilterChain bean with .requestMatcher(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN") restricts all Actuator endpoints.
Question 5: Which Actuator endpoint triggers a graceful application shutdown when HTTP POST is sent to it?
- /actuator/shutdown (Correct answer)
- /actuator/stop
- /actuator/exit
- /actuator/terminate
Correct answer: /actuator/shutdown
POSTing to /actuator/shutdown initiates a graceful shutdown; this endpoint is disabled by default for safety.
Question 6: What does the /actuator/caches endpoint allow you to do?
- View all registered caches and evict entries or entire caches via DELETE (Correct answer)
- Configure cache TTL values at runtime
- Monitor cache hit/miss ratios as Micrometer metrics
- Create new cache regions without restarting the application
Correct answer: View all registered caches and evict entries or entire caches via DELETE
The /actuator/caches endpoint lists all Spring-managed caches and supports cache eviction via HTTP DELETE requests.
Question 7: Which Micrometer class should you use to track the current size of a queue or collection in real time?
- Gauge (Correct answer)
- Counter
- Timer
- LongTaskTimer
Correct answer: Gauge
A Gauge is the correct Micrometer type for measuring an instantaneous value like current queue size or active thread count.
What happens when you annotate a method with @Timed from Micrometer in a Spring Boot application?