URL Health Monitor
A lightweight URL Health Monitoring application built with Node.js, Express, WebSocket, Axios, and Docker. The application periodically checks the health of registered URLs and updates the frontend in real time using WebSockets.
Features
-
Real-time URL health monitoring
-
Live updates using WebSockets
-
Register new URLs without refreshing the page
-
Periodic health checks
-
Displays:
- URL
- Status (UP/DOWN)
- HTTP Status Code
- Response Time
- Error Message
-
Stores monitoring history in JSON format
-
Simple frontend built with HTML and JavaScript
-
REST API for URL management
-
Docker and Docker Compose support
Project Structure
project/
│
├── backend/
│ ├── database/
│ │ ├── db.json
│ │ └── urls.json
│ │
│ ├── models/
│ │ ├── db_store_controller.js
│ │ ├── health_status_controller.js
│ │ └── url_store_controller.js
│ │
│ ├── routes/
│ │ └── url_routes.js
│ │
│ ├── utils/
│ │ └── utils.js
│ │
│ ├── .env
│ ├── app.js
│ └── web_socket_server.js
│
├── frontend/
│ ├── index.html
│ └── scripts.js
│
├── Dockerfile
├── docker-compose.yml
├── package.json
└── README.md
Technologies Used
Backend
- Node.js
- Express.js
- Axios
- WebSocket (ws)
Frontend
- HTML
- JavaScript
Storage
- JSON Files
urls.jsondb.json
DevOps
- Docker
- Docker Compose
How It Works
- The frontend loads all registered URLs from the backend.
- A WebSocket connection is established.
- The backend periodically reads all URLs from
urls.json. - Each URL is checked using an HTTP request.
- Response time and HTTP status are collected.
- Results are broadcast to all connected clients using WebSockets.
- The frontend updates the corresponding table row automatically.
- Every monitoring cycle is stored in
db.json.
Monitoring Flow
+------------------+
| urls.json |
+------------------+
|
v
Read Registered URLs
|
v
Perform Health Check
(Axios Request)
|
v
Collect Status & Response Time
|
+-------------+-------------+
| |
v v
Broadcast via WebSocket Save History
to Frontend to db.json
| |
+-------------+-------------+
|
v
Update UI in Real Time
API Endpoints
Get All Registered URLs
Request
GET /api/url
Response
["https://google.com", "https://github.com"]
Register a New URL
Request
POST /api/url/register
Request Body
{
"url": "https://openai.com"
}
Response
{
"message": "URL added successfully"
}
WebSocket
A WebSocket connection is established when the frontend loads.
The server continuously broadcasts health updates to all connected clients.
Example message:
{
"url": "https://google.com",
"status": "UP",
"statusCode": 200,
"responseTime": 84,
"error": null
}
The frontend updates the corresponding table row instantly without requiring a page refresh.
Monitoring History
Each monitoring cycle is stored in db.json.
Example:
[
{
"checkedAt": "2026-07-19T07:26:54.182Z",
"status": [
{
"url": "https://google.com",
"status": "UP",
"statusCode": 200,
"responseTime": 78,
"error": null
},
{
"url": "https://invalid-url.com",
"status": "DOWN",
"statusCode": "No Response",
"responseTime": null,
"error": "Request failed"
}
]
}
]
Frontend Features
The frontend displays:
- URL
- Current Status
- HTTP Status Code
- Response Time
- Error Message
- WebSocket Connection Status
- Refresh Counter
- Add URL Form
New URLs appear automatically without refreshing the page.
Error Handling
The application handles:
- Invalid URLs
- Connection refused
- Timeout errors
- HTTP error responses
- WebSocket disconnections
- File read/write errors
Configuration
The monitoring interval can be modified in:
backend/web_socket_server.js
Example:
setInterval(async () => {
// Perform health checks
}, 5000);
Docker Support
The project can be run using Docker and Docker Compose.
Build the Docker image
docker compose build
Start the application
docker compose up
Run in detached mode:
docker compose up -d
Stop the application
docker compose down
The application will be available at:
http://localhost:3000
The backend/database directory can be mounted as a Docker volume so that urls.json and db.json persist across container restarts.
Future Improvements
- Delete registered URLs
- Edit existing URLs
- Pause/Resume monitoring
- Configurable polling interval
- Search and filter URLs
- Dashboard with charts
- Authentication
- MongoDB or PostgreSQL storage
- Email or Slack notifications
- Historical analytics
- Export monitoring reports (CSV/PDF)
Author
Akshay Vadher
Backend Developer
License
This project is licensed under the MIT License.