Jamie Software Lab
Python Flask Monitoring DevOps

Uptime Monitor

Background thread pings the portfolio API and site every 60 seconds, recording response times. This page graphs the last 24 hours of data : pulled live from the server.

Ping interval60 seconds
History24 hours
BackendFlask + threading
StorageJSON file

Live Dashboard

Auto-refreshes every 30 seconds. Chart shows response time in ms over 24 hours.

Loading uptime data…

How it works

Thread starts
Daemon thread launches with the Flask app via gunicorn
Ping loop
Every 60s: HTTP GET to each target, record status + ms
Store
Append to JSON file, keep last 1440 entries (24h)
Serve
/api/uptime returns history; frontend draws Canvas chart

Decisions

Daemon thread, not cron

A daemon thread in the same process is simpler than a separate cron job. It dies with the app : no orphan processes, no separate deployment step.

JSON file, not a database

24 hours of 1-minute checks is ≈1440 entries per target : trivially small. A JSON file avoids a database dependency and is easy to inspect manually.

Canvas, not a chart library

Chart.js or D3 would be overkill for a single line chart. Drawing directly on Canvas keeps the page at zero dependencies.

Atomic file writes

Writes go to a temp file first, then os.replace() swaps atomically. Prevents corrupted reads if the API serves during a write.