HAP
All work02 / 15

Cloud Infrastructure

Sentinel: Out-of-Band Monitoring on Google Cloud

One Mac Studio runs about a hundred automations for us, plus three separate watchdogs meant to catch trouble. The catch is that all three watchdogs were running on that same machine. That is fine for the failures they were built for and useless for the one that matters most, because if the box goes down, so does everything that would have told you. Sentinel is the piece that lives somewhere else. It runs on Google Cloud, it is the only watcher outside that failure domain, and its whole job is to notice the silence.

Stack

Google Cloud RunFirestoreCloud SchedulerTerraformPythonSlack

Concepts

Independent failure domainHeartbeat monitoringWatching the watcherAlerts that claim only what they knowInfrastructure as codeKeyless deploys

How it works

The whole flow, traced from your first tap.

The studioGoogle CloudSlackBackstop
  1. 01

    The studio

    The machine checks in, every five minutes

    A small service on the Mac sends a short note upstream on a timer. It runs at the system level so it keeps reporting even when nobody is logged in, which is the exact situation it exists to describe.

    Runs as a system serviceSurvives logoutSigned message
  2. 02

    The studio

    It reports more than being switched on

    The note carries whether a user session is actually loaded and how many jobs are running inside it. A machine that is powered on but logged out is the failure that a simple up-or-down check misses entirely.

    Session checkJob countTime since last boot
  3. 03

    Google Cloud

    The message is checked, not believed

    Anyone can reach the endpoint, so nothing is trusted for being on the right network. Only a machine holding the key can claim to be that machine, and a message cannot be captured and replayed later to fake a heartbeat.

    Signed with a shared keyReplays rejectedNothing trusted by network position
  4. 04

    Google Cloud

    The cloud decides, on its own clock

    Something in the cloud wakes up on a schedule and looks at when each machine last spoke. The machine is never asked how it is doing, because that is the one answer you cannot get from a machine that is gone.

    Runs every five minutesReads the last check-inTolerates a few misses
  5. 05

    Slack

    The alert goes somewhere else on purpose

    Machine alerts land in a different place from everything the studio itself sends, so a broken token on the Mac cannot take the infrastructure alarms down with it.

    Separate channelSeparate credentialsShared with the team
  6. 06

    Slack

    Proof of life every Monday

    A working alarm and a dead one are both silent, so once a week it says something out loud. If Monday comes and nothing arrives, the alerting is what is broken.

    Weekly check-in messageSame path as a real alertReports what it can see
  7. 07

    Backstop

    And if the watcher stops

    A second alarm watches for our service going quiet, runs on infrastructure we do not maintain, and reports by email. If the chat path is what failed, an alert about it over chat never arrives.

    Google Cloud MonitoringEmail, not chatIndependent of our code

The problem

A watchdog that lives on the machine it watches can only report problems the machine survives. Lose power, lose the network, or have a reboot land somewhere unexpected, and the work stops and the alarm stops together. Nothing rings. From the outside, a studio humming along and a studio that died at two in the morning look exactly the same: quiet.

The failure that would have gone unnoticed for days

The machine does not log in by itself, and most of the automations need a logged-in session to run. So the shape of a bad night is this: the power flickers, the machine reboots the way it is supposed to, and it comes back sitting at the login screen. The hardware is fine. It answers pings, the fans are spinning, every simple up-or-down check in the world says green. And eighty-odd jobs are dead and will stay dead until somebody walks over and types a password. An ordinary heartbeat would have sailed straight through that. So ours does not just say the machine is alive. It says whether anyone is actually logged in and how many jobs are loaded, and if that number falls through the floor while the machine keeps answering, that is its own alarm.

It only claims what it can prove

From the cloud, a dead machine and a dead internet connection look identical. There is no way to tell them apart from the outside, so the alert does not pretend to. It says there has been no heartbeat from the studio in the last fifteen minutes, which is exactly true, and it never says the studio is down, which would be a guess. Small thing, but it decides whether you trust the next one.

Something has to watch the watcher

Here is the uncomfortable part of building a thing that alerts you: working perfectly and being completely broken both look like silence. If the webhook gets revoked on a Tuesday, nothing happens, and nothing keeps happening, and you feel fine about it. So every Monday morning it posts proof of life to the same channel a real alert would use, down the same path, through the same credentials. If that message does not arrive, the alerting is broken and you know within a week instead of finding out during an actual outage. Underneath that sits a second alarm run by Google's own monitoring, on infrastructure we do not control and code we did not write, watching for our watcher going quiet. It sends email rather than chat, on purpose. If chat is the thing that broke, an alert about it over chat never arrives.

You can rehearse the alarm

Testing a fire alarm by waiting for a fire is a bad plan. There is a command that deliberately makes the studio go quiet for a set window, in production, so you can sit and watch a real alert land on a real phone and then watch the recovery message follow it. The mute is capped, so a drill somebody forgot to end cannot silence the machine indefinitely, and it clears itself and starts reporting again on its own.

Naming what broke while the lights were off

When the machine comes back, the useful question is not that it went down, it is what did not run while it was gone. Each job reports its runs outward as it goes, so the recovery message can hand you the actual list of names: what should have run during the window and did not. That used to be an hour of reading logs and guessing.

Outcome

The whole thing is defined as code and rebuilt from that definition rather than clicked together in a console, and it deploys without a stored password existing anywhere for someone to find. It costs a couple of dollars a year to run. The original watchdogs all still run, because they catch different things. Sentinel exists for the failure none of them could ever report: the machine going quiet, and nobody hearing about it.

Interested in something similar?

Tell us what you need and we'll figure out how to ship it.

Get in touch