2 min read

CloudBeat Monitor

In a recent post, I discussed how I installed AdGuard Home on a Google Cloud Platform instance. For security purposes, I configured the server so that only devices connected to my Tailscale network could use AdGuard's DNS filtering and access its administration interface. Occasionally, the server hosting AdGuard can hang, requiring a manual reboot — a process that I don't want to deal with since the issue can be a nuisance to confirm and distracting to correct. To streamline this, I created a little project called CloudBeatMonitor that does not require access to the Tailscale network and can reboot the VM if it appears unresponsive.

Every minute, the VM sends a heartbeat with the current timestamp. This heartbeat is then tracked, and if the system fails to receive a new heartbeat within a two-minute interval, it automatically initiates a reboot of the VM.

CloudBeat Monitor is made up of two Google Cloud Functions that run outside the Tailscale network, yet are engineered to maintain the uptime and reliability of the VM within the Tailscale network. The first function receiveHeartbeat is triggered by a cron job running on the VM, which sends a heartbeat to Firestore every minute. The second function checkVMHeartbeatAndRestart, activated by Google Cloud Scheduler, checks if the most recent heartbeat is older than two minutes and, if so, restarts the VM to resolve any issues.

For anyone interested CloudBeatMonitor is on GitHub and includes the Cloud Functions, the cron job, and the Google Cloud Scheduler configuration. As of the time of publishing, it's worth noting that all of these services run within GCP Free Tier limits so there's no cost to use them.

GitHub - danielraffel/CloudBeatMonitor
Contribute to danielraffel/CloudBeatMonitor development by creating an account on GitHub.