Entry 06Platform · reliability2026

Origin Sentinel: detecting dead services behind a healthy Cloudflare edge

Cloudflare Tunnel carries outside traffic to services on a private network. Its edge (Cloudflare's servers facing the internet) can report healthy while the service behind it is broken. I built Origin Sentinel, an automated monitor that checks the origin (the service itself) directly and classifies what is wrong.

watchesthe origin
first releasereport-only
API tokenread-only
repairstaged

How a healthy tunnel can hide a failed service

Edge and tunnel status answer one question: is the tunnel connected? They do not say whether the service behind the tunnel is alive.

A container reboots, and DHCP gives it a new LAN IP. The tunnel ingress (the rule mapping a public hostname to an internal address) still points at the old address. The edge then serves errors, or a different service, while every dashboard stays green. Monitoring that checks only the edge and the tunnel does not see this, because the failure sits between the tunnel and the service. I call this class of failure a silent origin behind a healthy edge.

How the sentinel classifies origin state

The sentinel probes each origin from the local network side, so its probes bypass Access (Cloudflare's login gate in front of the services). It classifies the state before it changes anything. It proposes a repoint, changing the ingress rule to the container’s new address, only when a container’s IP has changed.

Everything it finds is written to a machine-readable health.json file, so the next automated agent, or a person, starts from the recorded findings instead of diagnosing the problem again from scratch.

Each origin is sorted into one of the six states shown here. Only STALE_INGRESS_IP, the case where a container’s IP has changed, leads to a proposed repoint.

origin state
OK
STALE_INGRESS_IP   -> propose repoint
DEAD_ORIGIN
TUNNEL_DOWN
APP_UNHEALTHY
NEEDS_HUMAN

How the sentinel limits the risk of automatic repair

Automatic repair that can rewrite production ingress could take services down if it acted wrongly, so most of the engineering limits what the sentinel may do. The first version only reports, and write access is planned for a later phase. In the report-only version these limits apply:

  • It writes proposed repoints into health.json and makes no Cloudflare changes.
  • The API token it uses has read permission only, so it cannot change anything.
  • A failure on one origin does not stop the checks on the others.
  • Writes to the file that records repair state are atomic: a write either completes or leaves the old file in place.

The repair logic that will apply repoints once write access is granted has its own limits:

  • Localhost origins (services addressed as running on the same machine as the tunnel) are excluded from automatic repointing.
  • Confirming a repair requires the service to return a 2xx HTTP status (a success response).
  • A repoint preserves every existing config key (each named setting in the configuration) and handles hostnames that have several ingress rules.

The decision logic is a pure functional core: it takes data, returns data and does no I/O (no network or file access). Network and file access happen in a thin outer layer of code around it, and 63 tests cover the core.

Platform / reliability Cloudflare Python Self-Heal

Interested in this kind of work? Email is best — [email protected] · Back to portfolio