Terraform and Grafana Synthetic Monitoring

Introduction

I’ve been putting together a small Terraform module for creating Grafana Cloud synthetic monitoring checks. Instead of defining each check separately, the module accepts a map of endpoints and creates the HTTP checks from that. It defaults to HTTP checks using the London probe, which is a good starting point for monitoring a few public endpoints.

Grafana Cloud’s free tier includes 100,000 API test executions and 10,000 browser test executions each month. This module is intended for HTTP/API checks and works out a sensible interval from the 100,000 available executions. As more endpoints are added, the available executions are divided across them, rounded to the nearest five minutes and kept at a minimum of one minute. This means I can add checks without having to manually recalculate the frequency each time, while still keeping an eye on the allowance being used.

module "synthetic_monitoring" {
  source = "./modules/synthetic-monitoring"

  endpoints = {
    "website" = {
      target = "https://greg.sharpe.wales"
    }
  }
}