OkStatus Now Supports Terraform
Define uptime monitors, heartbeat checks, alert channels, and internal workers as code. The OkStatus Terraform provider is now available.
OkStatus Team
Managing monitoring through a dashboard doesn't scale. You click around, create monitors, forget what you configured, and eventually your monitoring setup drifts from reality. Your infrastructure is in Terraform. Your monitoring should be too.
Today we're releasing the OkStatus Terraform provider.
Define monitors as code
terraform {
required_providers {
okstatus = {
source = "okstatushq/okstatus"
version = "~> 1.0"
}
}
}provider "okstatus" {
api_key = var.okstatus_api_key
}
resource "okstatus_notification_channel" "slack" {
name = "Engineering Alerts"
kind = "slack"
slack_config {
webhook_url = var.slack_webhook_url
}
}
resource "okstatus_monitor" "api" {
name = "Production API"
kind = "http"
check_config {
interval_secs = 60
http {
url = "https://api.example.com/health"
method = "get"
timeout_ms = 5000
}
}
alert_config {
targets {
channel_id = okstatus_notification_channel.slack.id
}
}
show_on_status_page = true
}
This monitor lives in your repo. It goes through code review. It deploys with your infrastructure. When someone asks "what are we monitoring?" the answer is in Git.
The provider supports every monitor type: HTTP, TCP, ping, DNS, SSL certificate expiry, and heartbeat. Notification channels can be email, Slack, webhook, or PagerDuty.
Heartbeats work too
resource "okstatus_monitor" "nightly_backup" {
name = "Nightly Backup"
kind = "heartbeat" check_config {
interval_secs = 86400 # expect a ping every 24 hours
heartbeat {
grace_period_secs = 1800
}
}
alert_config {
targets {
channel_id = okstatus_notification_channel.slack.id
}
}
}
Your cron jobs and background tasks get the same treatment. Terraform doesn't expose the heartbeat key yet, so once the monitor exists, rotate its key from the monitor's edit page in the dashboard to get one. Add a request to the heartbeat URL at the end of your job, and you'll be alerted if it stops checking in.
Internal workers, in code
On the Team plan, you can define internal workers alongside the monitors they run. They monitor services inside your network that aren't reachable from the internet.
resource "okstatus_worker" "dc_east" {
name = "dc-east-worker"
}resource "okstatus_monitor" "internal_db" {
name = "Internal Database"
kind = "tcp"
is_internal = true
worker_id = okstatus_worker.dc_east.id
check_config {
interval_secs = 30
tcp {
host = "internal-db.local"
port = 5432
}
}
}
The worker's API key is available as a sensitive Terraform attribute, so you can pass it straight into the deployment that runs the worker container.
Getting started
The provider is available on the Terraform Registry. It manages monitors, notification channels, internal workers, and API keys. Full documentation is on the registry. Status page settings are managed in the dashboard for now.
The provider works on every plan. Internal workers require the Team plan.
Your infrastructure is code. Now your monitoring is too.