Your monitoring and your public status page, kept in git and rolled out with
terraform apply. This repo is a working starting point: clone it, point it at
your services, and you have monitors, a status page, charts and a maintenance
window from one file.
Works with Terraform 1.5+ and with OpenTofu.
The root config creates:
- three services (two HTTP checks and one TCP check), tagged
env:production - a status page with a "Core services" group, uptime bars, and a component that has no check behind it (for the things you flip by hand)
- a response-time chart with the website and the API in the same graph
- a maintenance window, announced on the page, that starts itself
The defaults point at example.com, so the first apply comes up green before
you have changed a thing. Swap in your own targets when you are ready.
In the console, go to Settings > API Tokens and create one (Team plan or higher). This example needs:
services.view services.create services.edit services.delete
statuspages.view statuspages.create statuspages.edit statuspages.delete
maintenances.view maintenances.create maintenances.edit maintenances.delete
If you want the page to go live from Terraform, add statuspages.publish.
export LIVCK_API_TOKEN="lvk_..."
terraform init
terraform applyOpen the statuspage_url output in a browser. Then run terraform plan again:
it should report no changes. That empty plan is the point of the whole exercise.
What you wrote down is what LIVCK serves back.
To use your own services, copy terraform.tfvars.example to
terraform.tfvars and edit it. That file is gitignored.
Rename a component, add a service, add a probe to var.probes, and apply
again. A few things worth trying:
# Check from two locations instead of one
terraform apply -var='probes=["ffm","vie"]'
# See where you can check from
terraform output probe_locationsProbes are referenced by their code (ffm, vie, waw), not by an id, so the
config stays readable. How many locations one service may use depends on your
plan; go over it and the API says so.
If you built things in the console first, bring them under Terraform without recreating them:
terraform import livck_service.website <service_id>
terraform import livck_statuspage.main <statuspage_id>
terraform import livck_tag.env <tag_id>
# Nested resources take the parent id first
terraform import livck_statuspage_component.website <statuspage_id>/<component_id>
terraform import livck_statuspage_metric.latency <statuspage_id>/<metric_id>
terraform import livck_statuspage_metric_series.latency_website \
<statuspage_id>/<metric_id>/<series_id>The ids are in the console URLs and in every API response.
One caveat: a few things cannot be read back, because the API never returns them. Secrets inside a service config, a status page password, the local path of an uploaded logo, and the maintenance notify flags all fall into that category. After importing such a resource the first plan shows a one-off change that writes your configured values back. Apply it once and you are in sync.
terraform destroyexamples/public-dns-watch/ monitors Cloudflare, Google and Quad9 from several
European probes. It is the one to read if you want to see for_each over a map
of targets, three check types next to each other, and charts that compare all
three resolvers in a single graph.
| File | What it holds |
|---|---|
versions.tf |
provider requirement |
provider.tf |
provider config, token comes from the environment |
variables.tf |
targets, probes, endpoint |
main.tf |
the setup itself |
outputs.tf |
status page URL, probe list, service ids |
terraform.tfvars.example |
copy to terraform.tfvars and edit |
Set endpoint in terraform.tfvars, for example a local development stack:
endpoint = "http://localhost:8000/api"