Part K. Monitoring and alerts
K.1 What watches what
Section titled “K.1 What watches what”| Watcher | Detects | Tells you by |
|---|---|---|
| Free external uptime monitor on https://api.bideward.com/health | The whole path is down (server, tunnel, hub or Cloudflare) | Telegram and email |
| Cloudflare tunnel health alert (D.9) | The tunnel disconnected | |
| Lightsail alarms (below) | The instance itself is unhealthy | |
| systemd failure hook | A service stopped for good (after repeated crashes) | Telegram |
| bideward-watch (a small check every minute) | Slow signs: disk, memory, swap, queue, backup age, certificates, tunnel readiness | Telegram, once per change |
| The dashboard’s own alerts | A bot stuck or quota reached, as today | Telegram, as today |
The numbers behind the queue and flush checks come from curl -s http://127.0.0.1:8080/health/detail on the server (the public /health gives only ok). See E.5a.
K.2 The external monitor (this is the only thing that notices a dead server)
Section titled “K.2 The external monitor (this is the only thing that notices a dead server)”- Choose a free uptime monitoring service. UptimeRobot’s free plan checks every 5 minutes at the time of writing; verify the current limit and that it can send to Telegram.
- Create a monitor of type HTTPS for https://api.bideward.com/health with a 5-minute interval and the keyword “ok” as the success text. The public /health answers only that one word; the detailed numbers are on a different path that the WAF blocks from the outside and only the server can read.
- Add your Telegram and your email as alert contacts. Test it by stopping the hub for one check interval (sudo systemctl stop bideward-hub, then start it again).
K.3 Lightsail alarms
Section titled “K.3 Lightsail alarms”- Lightsail → Instances → bideward → Metrics → choose Instance status check failed → Add alarm. Contact: your email (add and confirm it in Lightsail’s notification contacts the first time). Trigger when the value is above 0 for 2 of 2 data points.
- Add a second alarm on CPU utilization above 80 percent for 3 of 3 data points of 5 minutes, and a third on Burst capacity (percentage) below 20 percent (the small plans slow down when the burst allowance is used up).
K.4 The failure hook and bideward-watch (from the repository, pull request 3)
Section titled “K.4 The failure hook and bideward-watch (from the repository, pull request 3)”All of it is installed by sudo /opt/bideward/hub/deploy/install.sh (F.5); the settings are in /etc/bideward/alert.env (TELEGRAM_TOKEN, TELEGRAM_CHAT_ID, root only). Then enable the timer: sudo systemctl enable --now bideward-watch.timer. Test the message path once: sudo systemd-run --wait --pipe -p EnvironmentFile=/etc/bideward/alert.env /usr/local/sbin/bideward-alert --text "Bideward test message" should put the text in your Telegram chat.
- bideward-alert@.service sends a Telegram message with the unit name and the last 10 log lines when a unit fails (long keys and password=… values in those lines are replaced by
<hidden>). A one-line drop-in, OnFailure=bideward-alert@%n.service, is added to bideward-hub, bideward-research, cloudflared-bideward, bideward-backup and postgresql, together with StartLimitIntervalSec=300 and StartLimitBurst=5, so a crash loop ends in “failed” and a message instead of silently restarting forever. - bideward-watch.timer runs bideward-watch every minute and keeps its last state in /var/lib/bideward-watch/state, so each problem is reported once when it starts and once when it clears (“… is fine again”), not every minute. The hub check reads
/health(and/health/detailfor the queue). Because/healthsaysdownwhile the hub does not hold the database lock (E.4), a lost lock is reported like any other hub failure.
| Check | Warn when |
|---|---|
| Disk (/) | More than 80 percent used |
| Memory | Available under 150 MB |
| Swap | More than 300 MB in use |
| Load average | Above 2.0 for 10 minutes |
| Hub health (local) | Fails twice in a row |
| Write queue | Above 1,000 entries, or flush time above 500 ms |
| Tunnel readiness (127.0.0.1:20241/ready) | Not ready for 2 minutes |
| Last backup | Older than 26 hours or last status failed |
| PostgreSQL connections | Above 30 of 40 |
| Pending OS updates needing a reboot | Reported once a week |
K.5 Monthly care list (30 minutes, same day each month)
Section titled “K.5 Monthly care list (30 minutes, same day each month)”- sudo apt update and sudo apt upgrade; the cloudflared package comes from Cloudflare’s source and is not covered by the automatic security updates, so it is updated here. If sudo needrestart asks to restart services, accept; if the kernel changed, reboot at a quiet time and run the reboot check of I.2.
- Check Node’s release page for a security release of your LTS line and update as in F.1 if needed.
- Look at Cloudflare → Security → Events for the month: anything blocked that should not have been, anything allowed that looks like a scan.
- Look at the dashboard’s audit trail for actions you do not recognise.
- Run the J.5 restore drill.
- Confirm two-factor is still on for Cloudflare, GitHub, AWS and Tailscale, and that the Tailscale machine list shows only your own devices and the server.
- Check that df -h shows the dumps folder is not growing beyond 14 days of files.
← Previous: Part J. Backups and restore · Guide index · Next: Part L. If something goes wrong, and retiring the old Worker →