Practice
1. Why is monitoring important in a Spring Boot application?
easy
Solution
Step 1: Understand monitoring purpose
Monitoring tracks app health and performance in real time.Step 2: Identify benefits in Spring Boot context
It helps find and fix issues quickly, ensuring smooth operation.Final Answer:
It helps detect problems early and keeps the app running smoothly. -> Option DQuick Check:
Monitoring = Early problem detection [OK]
Hint: Monitoring = early problem detection and smooth running [OK]
Common Mistakes:
- Thinking monitoring fixes bugs automatically
- Believing monitoring slows the app down
- Confusing monitoring with testing
2. Which Spring Boot dependency is commonly used to add monitoring features?
easy
Solution
Step 1: Identify monitoring-related starter
Spring Boot Actuator provides built-in monitoring endpoints.Step 2: Match dependency to monitoring
spring-boot-starter-actuator adds monitoring and health check features.Final Answer:
spring-boot-starter-actuator -> Option BQuick Check:
Actuator = monitoring starter [OK]
Hint: Actuator starter adds monitoring endpoints easily [OK]
Common Mistakes:
- Choosing web starter which is for web apps
- Confusing data-jpa with monitoring
- Selecting security starter unrelated to monitoring
3. Given this Spring Boot Actuator endpoint configuration:
What will be the output when accessing
management.endpoints.web.exposure.include=health,infoWhat will be the output when accessing
/actuator/health?medium
Solution
Step 1: Check exposed endpoints
Only 'health' and 'info' endpoints are exposed via web.Step 2: Understand default health output
By default, health endpoint returns {"status":"UP"} if app is running well.Final Answer:
{"status":"UP"} -> Option CQuick Check:
Health endpoint = {"status":"UP"} when healthy [OK]
Hint: Health endpoint shows status UP if app is healthy [OK]
Common Mistakes:
- Expecting error when endpoint is exposed
- Confusing info endpoint output with health
- Assuming status DOWN without failure
4. You added Spring Boot Actuator but
/actuator/health returns 404 error. What is the likely cause?medium
Solution
Step 1: Confirm Actuator dependency presence
If dependency was missing, app wouldn't compile or actuator endpoints wouldn't exist.Step 2: Check endpoint exposure settings
By default, some actuator endpoints are disabled or not exposed over web, causing 404.Final Answer:
The endpoint is disabled or not exposed in configuration. -> Option AQuick Check:
Disabled endpoint = 404 error [OK]
Hint: Check actuator endpoint exposure settings if 404 occurs [OK]
Common Mistakes:
- Assuming missing dependency without checking config
- Thinking app not running causes 404 instead of connection error
- Using wrong URL path for actuator endpoints
5. You want to monitor custom metrics in your Spring Boot app. Which approach best fits this need?
hard
Solution
Step 1: Understand custom metrics requirement
Custom metrics need to be collected and exposed in a structured way.Step 2: Identify Spring Boot recommended method
Micrometer integrates with Actuator to add and expose custom metrics easily.Final Answer:
Add custom metrics using Micrometer and expose them via Actuator endpoints. -> Option AQuick Check:
Micrometer + Actuator = custom metrics [OK]
Hint: Use Micrometer with Actuator for custom metrics [OK]
Common Mistakes:
- Relying only on logs for metrics
- Using default health endpoint for custom metrics
- Disabling Actuator loses monitoring benefits
