Aviary
Concepts

Fleet and health checks

Health checks, instance heartbeats and the Fleet page — which instances are up, deploys and their rollout, restart loops, and failing checks with the exceptions recorded since.

Every instance can send a heartbeat with its version, its state, the results of its health checks, and (for a tenant) its send buffer. The app that keeps the fleet turns those heartbeats into the Fleet page, the telescope_get_fleet MCP tool, and fleet alert rules. That app is a control plane, or a standalone app with fleet: true.

TopologyDefault
standaloneOff. fleet: true (or fleet: { … }) makes the app keep a fleet of its own replicas, which beat in process.
control planeOn. It keeps the fleet: tenants' heartbeats and its own.
tenantOn. Its heartbeat rides its batches (heartbeat next to entries) over every transport. It takes no buffer slot, since only the newest heartbeat is kept. A control plane that predates the fleet ignores it.

Health checks

import { TelescopeModule, checks } from '@dudousxd/nestjs-telescope';

TelescopeModule.forRoot({
  checks: [
    checks.redis({ client: redis }), // PING, a 10 s write, warn at 90% of maxmemory
    checks.terminus('db', () => db.pingCheck('db')), // any @nestjs/terminus indicator
    checks.custom('stripe', async () => ({ status: 'ok' })),
  ],
  health: { probes: true },
});
  • checks.redis({ client }) sends PING, then writes a key that expires after 10 s. A Redis at maxmemory with noeviction still answers PING but refuses writes, so the write catches that case and the check is down. The check is warn at memoryWarnRatio (0.9) of maxmemory.
  • checks.terminus(name, fn) maps an @nestjs/terminus indicator: up is ok, and down or a throw is down.
  • checks.custom(name, run) answers { status: 'ok' | 'warn' | 'down', message? }. A throw is down.

Each check is cached for cacheFor (default 30s) and single-flight, and it is down after timeout (default 5s). critical: false keeps a check out of readiness.

With health: { probes: true } two unauthenticated routes answer. Their bodies carry check names and statuses only, never messages.

RouteAnswers
GET <path>/api/probes/ready200, or 503 while a critical check is down or the instance is draining (from the shutdown signal on)
GET <path>/api/probes/live200 while the process answers. It never runs the checks.

Heartbeats

An instance beats every fleet.interval (15s). Its state is starting until the app has booted, then ready, then draining once shutdown begins.

fleet optionDefaultWhat it does
enabledsee aboveSend heartbeats and keep the fleet.
interval'15s'How often each instance beats.
appAPP_NAME, else package.json name, else 'app'The name of a standalone app or control plane in the fleet. A tenant is named by its token.
versionfirst of GIT_SHA, COMMIT_SHA, SOURCE_VERSION, RENDER_GIT_COMMIT, RAILWAY_GIT_COMMIT_SHA, VERCEL_GIT_COMMIT_SHA, HEROKU_SLUG_COMMIT, K_REVISION, else package.json versionThe deployed version (a string or a function).
hostHOSTNAME, else the OS hostnameHost or pod name.
goneAfter3An instance is gone after this many of its own intervals without a heartbeat, measured on the receiver's clock.
retention'7d'How long a gone instance is kept, along with its deploy and restart history.
restartLoop{ restarts: 3, within: '10m' }What counts as a restart loop on one host.
storein memoryWhere instances are kept: any FleetStore (upsert, list, prune).
urlAPP_URLThe URL other apps reach this one at, sent with each heartbeat for service discovery. A worker never sends it.
roledetectedWhat this process is: 'web' or a worker's name. See Workers.
report['web', 'worker']Which kinds of process report. ['web'] keeps workers out of the fleet.
workerAfter'30s'How long a process without an HTTP server runs before it reports as a worker.

The default store is in memory. A control plane with several replicas behind a load balancer keeps one fleet per replica. Run one control plane replica, or pass a shared FleetStore.

Workers

Long-running processes that are not the HTTP server (a worker started with NestFactory.createApplicationContext, BullMQ processors, @dudousxd/nestjs-durable workers, a microservice) appear in the fleet next to the web instances, with a role:

ProcessRoleReports
NestFactory.create (an HTTP adapter)webfrom boot: starting, then ready
No HTTP adapter (createApplicationContext, a microservice)what marked it (bullmq, bullmq+durable), else workeronce it has run for workerAfter (30s), as ready
No HTTP adapter, with fleet.rolefleet.roleright away, as ready
A short command (a migration, a script) that exits before workerAfter—never
// worker.ts: a dedicated worker process
const app = await NestFactory.createApplicationContext(WorkerModule);
app.enableShutdownHooks();
// TelescopeModule.forRoot({ ..., fleet: { role: 'billing-consumer' } }) to name it and report at once
  • Naming. The BullMQ watcher marks a process that has @Processor classes as bullmq. Any library or app code can do the same with markFleetWorker('name') (it returns the release), or structurally through the Symbol.for('@dudousxd/nestjs-telescope:fleetWorkers') map on globalThis, so a library needs no telescope dependency. A process serving HTTP stays web whatever runs in it.
  • Lifecycle. A worker goes through the same states: ready, draining on shutdown (app.close(), or SIGTERM/SIGINT even without enableShutdownHooks(): a listener that only observes, and re-raises the signal when it is the only one, so the process exits as before), then gone.
  • Health checks run in a worker and ride its heartbeat; there is no HTTP route to probe. It sends no url, so service discovery never routes to it.
  • Compatibility. The role is an additive heartbeat field. A heartbeat without one (an older tenant) is web, and an older control plane ignores it.

Watchers in the heartbeat

Each heartbeat also lists the watchers its process runs (watchers: request, query, job, …). A control plane's entries come from its tenants, so its console asks them, not itself, whether a type is recorded: GET meta watchers is the union of what the instances of the apps in view report (narrowed by ?app= and the viewer's apps), plus the control plane's own when every app is in view. The watcher-driven nav and the Overview's "Not measured" notes follow it.

When an app in view runs a version whose heartbeat carries no watchers, or the control plane keeps no fleet (fleet: false), watchers is left out of meta: the console then shows every type and claims nothing is off. Instances last seen before the retention window (prune.after, else 24 h) are not counted. A standalone app answers with its own watchers, as before.

What the Fleet page shows

Monitor → Fleet (also in ⌘K) re-reads every 15 s and shows, for each app:

  • Instance counts. Up, starting, draining and gone, plus the tenant send buffer (waiting, dropped, lag).
  • Every instance. Host, role (web or a worker's name), status, version, uptime, when it was last seen, health, and its buffer.
  • A role filter (All roles, web, bullmq, …) once more than one role runs. It recounts the cards and narrows the instances and restart loops; deploys, failing checks and the send buffer, which cover every role, are hidden while a role is picked.
  • Deploys. Each version change with its rollout: 2/5 live, complete, or no live instances. A draining instance on the old version keeps a rollout incomplete.
  • Restart loops. Counted per host and role, so a container booting its web process and a worker is not two restarts. For example, shop-worker-0 (bullmq) restarted 3 times in 7 min.
  • Failing checks. For example, Redis: down for 12 min on 4 of 4 instances, with the exception families recorded since. Click one to open its entry.

GET <path>/api/fleet follows the console's scope:

  • ?app= narrows the view.
  • A viewer limited to some apps sees only those apps.
  • A viewer limited to some organizations sees nothing. Instances are shared by every organization, so the page explains that instead.

The Fleet item appears in the sidebar only where a fleet is kept.

Alerts

The fleet rules (instances-up, restart-loop, check-down, entries-dropped; see Alerts) work like every rule:

  • Routing. They take severity and channels. The default severity is critical for instances-up and check-down, error for restart-loop and warning for entries-dropped.
  • One subject at a time. Each subject (an app, an app's check, a looping host and role) is raised once and cleared once.
  • Roles. instances-up counts an app's web instances (an app that only runs workers counts its workers), so a live worker never hides a web outage. role: 'bullmq' checks that worker (only the apps running it, without app), role: '*' every instance. The instances check state the heartbeat integrations follow uses the same rule.
  • Clears close the incident. The clear is a status: 'resolved' payload. It reaches the on-call, chat and email integrations, which close the incident keyed telescope:<app>:<rule>[:<check>][:<host>][:<worker role>] (a web subject keeps its key from before roles).
alerts: {
  app: 'ops',
  channels: [pagerDutyChannel({ routingKey: process.env.PD_KEY!, minSeverity: 'critical' }), slackChannel(url)],
  rules: [
    { type: 'instances-up', below: 2 },
    { type: 'check-down', check: 'redis', for: '5m' },
    { type: 'restart-loop', channels: ['slack'] },
  ],
  heartbeats: [{ provider: 'healthchecks', url: process.env.HC_URL!, apps: { shop: process.env.HC_SHOP_URL! } }],
},

The fleet also publishes its check states (publishCheckStates()): one state per app and check, plus an instances check per app. alerts.heartbeats, alerts.statusPages and uptimeHandler() therefore follow the fleet with no checkStates of their own. See Check states.

On this page