Menu

Star on GitHub · 3.1k
All posts

Monitors as code with Terraform

Define your monitors, alerts and status pages next to the infrastructure they watch, with the Navy Terraform provider.

Monitors as code with Terraform

Most teams create monitors by hand, one at a time, in a dashboard. That works for ten monitors. At a hundred, monitors drift out of sync with the services they watch. The Navy Terraform provider lets you define monitoring next to the infrastructure it covers.

1. Why monitors belong in code

When a new service launches, its monitors should launch with it. When a service is removed, its monitors should go too. Keeping both in the same repository means they are reviewed, versioned and deployed together.

2. Install the provider

Add the Navy provider to your Terraform configuration and set an API token from your workspace settings. The provider talks to the same REST API as the dashboard, so anything you can do by hand you can do in code.

3. Define a monitor

A monitor is a resource with a type, a target and a check interval. An HTTP monitor needs a URL, the expected status code and, if you want, a keyword to look for in the response. Regions default to all 18.

4. Attach alerts and escalation

Reference an alert policy from the monitor so every new service gets the right routing from day one. Escalation policies and on-call schedules are resources too, so the people who get paged are in version control as well.

5. Add monitors to a status page

Status page components can reference monitors directly. When a monitor opens an incident, the matching component on your status page updates. Adding a service to the page becomes a one-line change in a pull request.

6. Use modules for repeated patterns

Most services need the same set of checks: an HTTP monitor, an SSL certificate monitor and a heartbeat for background jobs. Wrap them in a module and reuse it for every service. New services get full coverage without anyone remembering a checklist.

7. Plan before you apply

Terraform shows exactly which monitors will be created, changed or removed before anything happens. Review the plan in CI like any other change. If you prefer YAML, the Navy CLI applies the same config without Terraform.

Tool Best for Config format
Terraform provider Teams already on Terraform HCL
Navy CLI Small teams and CI scripts YAML
REST API Custom tooling JSON

Monitors as code means monitoring is never an afterthought. Define it once, review it like code and let every deploy keep it up to date.

Keep reading

More from on call

View all posts
Many agents, one mind: how CyberStrike tests
researchOct 12, 2026

How we do agentic web testing

A short, first-person look at how CyberStrike splits a web assessment across specialist agents, keeps the reasoning with the AI, and uses a deterministic signal layer so evidence is never lost.

How we run Navy on Navy
newsJun 2, 2025

How we run Navy on Navy

We monitor our own checks, alerts and status pages with Navy. Here is what that setup looks like and what it has taught us.

Response time percentiles, explained
researchMay 30, 2025

Response time percentiles, explained

Averages hide the requests your users actually notice. Here is how to read p50, p95 and p99 response times.

Get the next post in your inbox

One email a month with new posts, product updates and the odd postmortem worth reading. Unsubscribe in one click.