# Under the hood

How the uptime probes are built, why the status page and the availability ledger live on them, and where metrics and logs are stored, with the measurements behind those decisions.

Monitoring has two parts worth opening up: the probes that run uptime checks from outside the
control plane, and the database that holds metrics and logs. The probe is a small Go program of
ours. The database is Postgres, and we decided not to write one. The decision that shapes the probe
is that nothing the SLA evidence depends on may run on the control plane: the platform's status page
and the minute-by-minute availability ledger are served from the probe's own disk, because a status
page on the control plane is down exactly when it is needed.

## What runs where

```text
control plane: decides every state, renders every status page
     ▲  every 5 s    the probe asks for its location's work
     │  every 1 s    results, batched
     │  every 30 s   the rendered platform status bundle
     │  every 5 min  the probe binary (self-update)
probe machine (one per location, small VM, no private network)
  ews-probe   runs the checks, socket pinned to the address
              asks the console's health endpoint every 30 s
              minute ledger on local disk
              serves status page + ledger, Caddy :443 in front
     ▼
checked targets on the internet
```

The probe pulls. Like our deploy agent it has no inbound command channel: every 5 seconds it asks
the control plane for its location's tasks, which doubles as its heartbeat, and sends results back
batched once a second. The control plane does the voting between locations; a probe never decides
a state. The same probes request each Managed Kubernetes cluster's API endpoint from outside.

Metrics and logs go the other way, from agents and SDKs into Postgres. Today they sit in the
platform's own database, unpartitioned, and a daily sweep rolls metrics up to hours after 14 days
and archives logs to object storage after 7, deleting the rows it has moved. Moving them into the
separate telemetry database, partitioned by day so that retention is a partition drop rather than a
`DELETE`, is decided and not built. Error events have their own store, described in
[App Monitoring under the hood](/docs/errors/guide/under-the-hood).

## What we built, and what we did not

### The probe

`ews-probe` is Go 1.23 with no dependency beyond the standard library, about 1,900 lines including
tests, a static binary for amd64 and arm64. It is the control plane's own check rules written in
Go, with the same result shape, so a check means the same thing from every location. The parts
that matter are about addresses: every DNS answer must be public, and the socket is pinned to the
address that was checked, so a name that changes its answer between resolution and connect (DNS
rebinding) cannot steer the probe into a private network. The machine's firewall, which drops
outgoing traffic to private ranges, is the second line.

We did not evaluate a hosted uptime service or the Prometheus blackbox exporter against it; no
such comparison is recorded. The probe came out of two constraints: the status page must survive
the control plane being down, and the SLA evidence must not depend on the control plane, because
while it is down the probe's results have nowhere to go, and the outage the SLA is about is the
one thing a control-plane-side record would miss.

### The ledger

Every minute the probe writes one byte to a file on its own disk: `1` when at least one of its
requests to the console's health endpoint got a 2xx in that minute, `0` when it asked and none
did, `.` when it was not running (counted neither way). That is 1,440 bytes a day, kept 400 days,
served on the status host as `/availability.json` and `/availability/YYYY-MM-DD`, so anyone can
recompute the figure from the raw minutes.

### One renderer, and the probe serves its bytes

Until 2026-11-20 the platform's status page was a Go template inside the probe and customers'
pages were a Next.js page: two renderers, and ours fell behind. One renderer on the control plane
now produces a static HTML document from a snapshot (no JavaScript, one style block under a CSP
hash, a self-hosted font). For the platform page it ships the same files as a bundle; the probe
keeps the bundle on disk, serves it, fills only three marked regions (whether the console answers
from here, the age of its copy, the ledger) and forwards subscribe forms to the control plane.
Rejected: two renderers with the design ported to Go (every improvement twice); React rendered to
static markup in a Next.js route (not callable from the worker, and the probe would still need its
own markup); the probe proxying the control plane's page (it dies with the control plane).

### Red only when two locations or a person confirmed it

On 2026-11-19 our own status page showed a red banner for object storage. The check requested a
URL that answers 403 by design, one probe location voted with `confirmations 1`, and the page
painted itself red and kept the outage in its history: 10.13 % uptime over 90 days for a service
that was up. A status page that cries wolf is worse than none.

Since then a component is a major outage only for an outage at least two locations saw fail, or
for an incident a person posted. One failing location shows as unconfirmed (amber) with its reason,
and its time still counts as downtime. A closed outage can be marked a check error: it stays,
drawn hatched and named, and leaves the uptime figure; nothing is deleted. Rejected: hiding
unconfirmed failures (a real outage seen from one location would show green); deleting a wrong
outage (the correction would be invisible); excluding unconfirmed time from uptime (the figure
would depend on whether the second probe was up).

### Where metrics and logs live

In November 2026 we asked whether to build our own telemetry database in Rust for the day
OpenTelemetry logs and traces arrive in volume. We measured instead (next section) and decided
against it:

- **Now: Postgres.** Built, backed up, highly available, transactional. Per-minute rollups with a
  mergeable sketch (t-digest or DDSketch), written at ingest so dashboards read rollups rather than
  raw rows, are the decided next step.
- **When logs and traces become a product: ClickHouse**, not built yet. It has the longest
  telemetry record (Sentry, PostHog, SigNoz, Uber, Netflix, Cloudflare), it was the fastest
  columnar engine in our measurements, and it would start as a single node fed from a Postgres
  staging table, so the acknowledgement stays a Postgres commit and ClickHouse gets batched,
  idempotent inserts. Against it: a second stateful system, a full copy per replica, Keeper.
- **Our own Parquet writer only as an archive tier**, later: one sorted file per tenant, signal
  and day on our object storage, with a catalogue in Postgres. As the store for queries we
  rejected it: its gap to ClickHouse is exactly a text index, a compactor and a cache, which is
  what building a database means, 12 to 16 engineer-weeks to reach roughly what GreptimeDB already
  is.
- **Metrics stay in Postgres** with rollups. Series, cardinality limits and alert evaluation are a
  different shape from spans and logs; a Prometheus-compatible product would run an existing TSDB
  (VictoriaMetrics or Mimir), never our own.
- **GreptimeDB and OpenObserve**: not now. GreptimeDB has been 1.x since April 2026 with no named
  production users; OpenObserve is AGPL and brings its own UI and tenancy.

Whatever the store, it gets a trace-id index, per-tenant admission limits, a tenant predicate
injected from the caller, idempotent batch ids and exact or t-digest quantiles.

## Benchmarks

**How to rerun these.** The engines' `docker run` lines are on this page; the generator and query
runner that loaded and queried them are an internal tool, not published. The engines, schemas and
data shape below are given in full, enough to rebuild the method.

### Telemetry store bake-off, 2026-11-20

Measured 2026-11-20, 10:28 to 10:52 UTC, on our shared `arm-16` test machine (16 Ampere Altra /
Neoverse-N1 cores, 32 GB) with other jobs running (load 2 to 4), so read ±20 % into any single
number. Three engines, one at a time, each in a container with 6 CPUs and 8 GB: Postgres 17 (day
partitions, btree on tenant and time, btree on trace id, a trigram GIN index on log bodies),
ClickHouse 26.8.40.7 (MergeTree partitioned by day, ordered by tenant and time, a bloom filter on
trace id, a token bloom index on log bodies), and DataFusion 55.3 reading Parquet (zstd 3, 64k
row groups, one file per tenant, signal and day) from SeaweedFS in a container (its `latest`
image, which we did not pin). The data: 20 M
OpenTelemetry-like spans and 10 M logs over 30 days for 20 tenants of Zipf-distributed size, the
largest (t0) holding 27 %. Real spans carry many more attributes, so absolute bytes are low for
every engine; the ratios carry over. Raw output is kept. The generator and query runner are a
Rust program of ours (internal tool, not published); the engines were started like this:

```sh
docker run -d --name tsb-pg --cpus 6 --memory 8g --shm-size 2g -p 127.0.0.1:55611:5432 \
  -e POSTGRES_PASSWORD=bench postgres:17-alpine \
  -c shared_buffers=2GB -c effective_cache_size=6GB -c work_mem=64MB \
  -c maintenance_work_mem=1GB -c max_wal_size=2GB -c max_parallel_workers_per_gather=6 \
  -c max_worker_processes=12 -c max_parallel_workers=12 -c jit=off
docker run -d --name tsb-ch --cpus 6 --memory 8g --ulimit nofile=262144:262144 \
  -p 127.0.0.1:55612:8123 -e CLICKHOUSE_SKIP_USER_SETUP=1 \
  clickhouse/clickhouse-server:26.8.40.7
docker run -d --name tsb-s3 --cpus 4 --memory 4g -p 127.0.0.1:55614:8333 \
  chrislusf/seaweedfs:latest server -dir=/data -s3 -volume.max=0
```

Bytes per row on disk, indexes included:

| Rows         | Postgres | ClickHouse | Parquet |
| ------------ | -------: | ---------: | ------: |
| Spans (20 M) |      237 |         35 |      28 |
| Logs (10 M)  |      370 |         48 |      36 |

Of the Postgres log row, 166 bytes are the trigram index. Before compaction, the largest tenant's
last hour as 10-second Parquet flushes was 346 files at 343 bytes a row, 12 times the compacted
size. Ingest per CPU-second of the engine, 6 writers:

| Path                                   | Rows per CPU-s |
| -------------------------------------- | -------------: |
| Parquet encode (arrow-rs), spans       |         1.10 M |
| ClickHouse insert from Parquet         |          335 k |
| Postgres `COPY`                        |           97 k |
| Postgres `COPY` plus the trigram index |           43 k |

Query latency, warm median of five runs in milliseconds, client wall time including the result
fetch. The last column models an HDD-backed object store with 50 ms per request:

| Query                                            | Postgres | ClickHouse | DataFusion, local | DataFusion, +50 ms |
| ------------------------------------------------ | -------: | ---------: | ----------------: | -----------------: |
| Errors in the last hour by service, t0           |      2.7 |       14.8 |              17.7 |                173 |
| p95 by route over 7 days, t0 (1.27 M root spans) |      550 |         50 |               138 |              1,214 |
| One trace by id, no time bound, t0               |      6.2 |         31 |                55 |              1,089 |
| Rare token in 7 days of logs, t0                 |      2.5 |         10 |                88 |                501 |
| Count of a phrase in 30 days of logs, t0 (2.7 M) |      785 |         94 |               165 |                739 |
| Per-minute error timeline, 24 h, t0              |      152 |         18 |                22 |                126 |
| Full scan, p95 by service over all 20 M spans    |   11,603 |         86 |               758 |              6,927 |

On the full scan Postgres spent 24.5 CPU-seconds, ClickHouse 0.47, DataFusion 2.2. Every engine
returned the same rows; ClickHouse's sampling `quantile` was 6 % off on the full scan, which is
why exact or t-digest quantiles are on the list above. Not shown:
concurrent queries from many tenants, real OTLP payloads with their attribute maps, small-batch
ingest, a cache in front of DataFusion, or GreptimeDB and OpenObserve themselves.

### The probe

We have no load measurement of the probe and make no throughput claim for it.

## Known limits

- With one probe location nothing automatic is ever red: a person declares the incident. A second
  location, ideally with another provider, is the next step; the planned locations share one
  provider and one autonomous system.
- The ledger lives on one disk; copying it off daily, and the combiner over two ledgers ("both
  must fail" per day line), are not built.
- A probe holds check results for one minute while the control plane is unreachable, then drops
  them; only the ledger keeps the console's own availability through such a gap.
- The status bundle carries at most 200 incident pages (its 90-day window), and the page has no
  script: no filter, no search.
- OTLP is metrics only, as JSON: no OTLP logs or traces endpoint, no protobuf.
- Per-minute sketch rollups are decided, not built, and so is the move of metrics and logs into
  the day-partitioned telemetry database. Postgres is 8 to 10 times the bytes of a columnar store, and a
  7-day aggregation over 1.3 M rows already takes 550 ms warm.

## Related

- [How Monitoring collects data](how-monitoring-collects-data.md)
- [How uptime checks work](how-uptime-checks-work.md)
- [App Monitoring under the hood](/docs/errors/guide/under-the-hood)
