Overview
Secure Link API provides comprehensive health monitoring through Spring Boot Actuator. The application implements custom health indicators for critical components including the database, file storage, and background schedulers.Health Endpoint
The main health endpoint is exposed via Spring Actuator:Overall application health status:
UP, DOWN, or OUT_OF_SERVICEHealth status of individual components
Example Response
Health Indicators
Database Health
Monitors database connectivity by executing a simple query. Implementation:br.com.walyson.secure_link.health.DatabaseHealthIndicator:19
UP- Database is reachable and responding correctlyDOWN- Database is unreachable or returning unexpected results
database- Connection status descriptioncheckedAt- Timestamp of the last successful check
Storage Health
Verifies that the file storage path exists and is writable. Implementation:br.com.walyson.secure_link.health.StorageHealthIndicator:18
UP- Storage path exists and is writableDOWN- Storage path doesn’t exist, is not writable, or an error occurred
app.storage.path property (default: /tmp/uploads/)
Scheduler Health
Monitors the background link expiration scheduler to ensure it’s running on schedule. Implementation:br.com.walyson.secure_link.health.SchedulerHealthIndicator:21
UP- Scheduler executed recently (within 2 minutes)OUT_OF_SERVICE- Scheduler has never run or hasn’t executed within the expected timeframe
scheduler- Status descriptionlastExecution- Timestamp of the last scheduler executiondelaySeconds- Delay in seconds (only when delayed)
Configuration
Enabling Health Endpoints
Health endpoints are enabled by including the Spring Boot Actuator dependency:Exposing Health Details
To expose detailed health information in production, configure:For security reasons, consider restricting detailed health information to authenticated users or internal networks in production environments.
Health Check Groups
You can create custom health groups for different purposes:/actuator/health/liveness/actuator/health/readiness
Kubernetes Integration
Use health endpoints for Kubernetes probes:Monitoring Best Practices
- Regular Polling - Configure your monitoring system to poll the health endpoint every 30-60 seconds
- Alert on Status Changes - Set up alerts when component status changes from
UPtoDOWNorOUT_OF_SERVICE - Track Health History - Log health check results for trend analysis
- Component Dependencies - The overall status is
DOWNif any critical component is unhealthy
The scheduler health indicator uses a
SchedulerExecutionRegistry component that tracks execution timestamps. Ensure your scheduled tasks call registry.markExecution() after each successful run.Troubleshooting
Database Health Failures
Symptoms: Database component showsDOWN status
Possible Causes:
- Database server is unreachable
- Connection pool exhausted
- Network connectivity issues
- Incorrect database credentials
Storage Health Failures
Symptoms: Storage component showsDOWN status
Possible Causes:
- Storage path doesn’t exist
- Insufficient permissions
- Disk full
- Path configuration incorrect
app.storage.path exists and has write permissions
Scheduler Health Failures
Symptoms: Scheduler component showsOUT_OF_SERVICE status
Possible Causes:
- Scheduler thread crashed or stopped
- Application restarted recently and scheduler hasn’t run yet
- Scheduler disabled or misconfigured
