Developers

Monitoring as code

Declare your UptimeWarden monitors in code. Apply from CI. Detect drift against the dashboard.

Monitoring as Code (MaC) is the practice of declaring your monitors in version-controlled config files instead of clicking through a dashboard. UptimeWarden ships a TypeScript-first CLI for this, @uptimewarden/cli.

Why TypeScript

The market splits into two patterns:

  • TypeScript-native (Checkly): best developer experience, monitors are typed objects, refactor-safe.
  • Terraform-only (Datadog, Better Stack, PagerDuty): friendly for procurement, less friendly for developers.

UptimeWarden offers both. The CLI is the on-ramp for engineers; the Terraform provider is the option for teams whose entire stack already lives in HCL.

The config file is JSON. Today the API refuses an unknown or mistyped field with a 400 that names it.

Config example

{
  "monitors": [
    {
      "externalId": "homepage-prod",
      "name": "API health",
      "type": "http",
      "url": "https://api.acme.com/health",
      "interval": 60,
      "timeout": 10,
      "region": "gwc"
    }
  ]
}

Apply with:

uw apply -f monitors.uw.json

The CLI config file carries only the fields above. The API takes every monitor setting with the dashboard's field names, so a monitor declared directly against /api/v1/monitors or through the Terraform provider can carry thresholds, verification regions (verificationRegions, minConfirmingRegions), alert routing (notifications, recipients, escalationPolicyId, selectedWebhookIds by public id) and heartbeat timing.

How drift detection works

Every monitor in UptimeWarden carries two metadata fields: a managedBySource source (manual, cli, terraform, or api) and an optional externalId. The CLI:

  1. Reads your config file and builds the desired set, keyed by externalId.
  2. Fetches the live set of monitors managed by the CLI for your account.
  3. Computes Create / Update / Delete by comparing the two sets.
  4. Refuses to touch monitors whose source is manual, those are dashboard-created and not yours to delete.

No state file, no out-of-band sync, drift is computed live on every run.

Without --yes, uw apply runs in dry-run mode: it prints the plan and writes nothing. With --yes it creates and updates monitors; add --allow-delete to also remove monitors no longer in the config. It never touches monitors whose source is manual.

Current release status

What ships today:

  • The config file is JSON.
  • Apply, uw apply --yes creates, updates, and (with --allow-delete) deletes monitors. Without --yes the run is dry-run.
  • Field-level drift detection across name, type, url, interval, timeout, region, isActive.
  • Single resource type: monitors, in the CLI and in the Terraform provider. Escalation policies, webhooks, status pages and on-call schedules are not managed as code; create them in the dashboard and reference policies and webhooks from monitors by public id (GET /api/v1/escalation-policies, GET /api/v1/webhooks).

See also

Bu sayfayı Türkçe okuyun