Monitoring & Health
Health Check - /api/health
-
Endpoint:
/api/health -
Method: GET
-
Description: Checks the health status of the application and database.
-
Response (healthy):
{
"status": "healthy",
"database": "connected",
"basicConnection": true,
"tablesFound": 2,
"tables": [
"servers",
"backups"
],
"preparedStatements": true,
"initializationStatus": "complete",
"initializationComplete": true,
"connectionHealth": true,
"timestamp": "2024-03-20T10:00:00Z"
} -
Response (degraded):
{
"status": "degraded",
"database": "connected",
"basicConnection": true,
"tablesFound": 2,
"tables": [
"servers",
"backups"
],
"preparedStatements": false,
"preparedStatementsError": "Prepared statement error details",
"initializationStatus": "complete",
"initializationComplete": true,
"connectionHealth": false,
"connectionHealthError": "Connection health check failed",
"connectionDetails": {
"additional": "diagnostic information"
},
"timestamp": "2024-03-20T10:00:00Z"
} -
Error Response (503):
{
"status": "unhealthy",
"error": "Database connection failed",
"message": "Connection timeout",
"stack": "Error: Connection timeout\n at...",
"timestamp": "2024-03-20T10:00:00Z"
} -
Notes:
- Returns 200 status for healthy systems
- Returns 503 status for unhealthy systems or prepared statement failures
- Includes
preparedStatementsErrorfield when prepared statements fail - Includes
initializationErrorfield when database initialization fails - Includes
connectionHealthErrorandconnectionDetailswhen connection health checks fail - Stack trace only included in development mode
- Tests basic database connection, prepared statements, initialization status, and connection health
- Provides comprehensive health diagnostics for troubleshooting