Synthetic Monitoring Patterns

Comprehensive guide to synthetic monitoring patterns for production observability and monitoring systems.

Synthetic monitoring is the practice of simulating user interactions with a system at regular intervals to detect failures, measure performance, and validate availability. It matters when you need to catch issues before real users encounter them—when latency spikes, service outages, or API regressions must be detected proactively, not reactively. Synthetic monitors run from external locations, mimicking real clients, and report outcomes through metrics, logs, and alerts. They are essential for service-level objectives (SLOs), platform health dashboards, and automated incident response.

Defining the Synthetic Monitor

A synthetic monitor is a repeatable, automated test that executes a sequence of operations against a system, typically over HTTP, and produces a result that includes timing, status, and diagnostic data. The monitor runs on a fixed schedule, often every 1 minute, 5 minutes, or 15 minutes, and is defined by a set of instructions, inputs, and expectations.

Each monitor is a self-contained unit that includes:

The monitor is defined as a configuration object, typically in JSON or YAML, and deployed as a unit to a synthetic monitoring platform.

Example Monitor Configuration (JSON)

{
  "id": "api-login-flow",
  "name": "Login Flow - API",
  "target": "https://api.example.com",
  "schedule": "every 5m",
  "timeout": 30,
  "steps": [
    {
      "name": "Fetch Login Page",
      "method": "GET",
      "path": "/login",
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.csrf_token", "required": true },
        { "type": "text", "value": "Welcome to Example App" }
      ]
    },
    {
      "name": "Submit Login",
      "method": "POST",
      "path": "/login",
      "body": {
        "username": "[email protected]",
        "password": "secret"
      },
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.user.id", "required": true },
        { "type": "json", "path": "$.token", "required": true }
      ]
    },
    {
      "name": "Fetch Dashboard",
      "method": "GET",
      "path": "/dashboard",
      "headers": {
        "Authorization": "Bearer {{token}}"
      },
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.user.name", "value": "Admin User" }
      ]
    }
  ],
  "alerting": {
    "thresholds": [
      {
        "metric": "latency",
        "condition": "avg > 1.0s",
        "duration": "3 consecutive runs"
      },
      {
        "metric": "status_code",
        "condition": "any_step failed",
        "duration": "2 consecutive runs"
      }
    ],
    "notifications": [
      {
        "channel": "email",
        "recipients": ["[email protected]"],
        "on": ["latency", "failure"]
      },
      {
        "channel": "webhook",
        "url": "https://alerting.example.com/webhook",
        "payload": {
          "monitor": "{{id}}",
          "timestamp": "{{timestamp}}",
          "failures": "{{failures}}"
        }
      }
    ]
  }
}

The key to synthetic monitoring is the *step definition*: a sequence of operations that mirror real user journeys. Each step has a name, HTTP method, path, optional headers, body, and a set of assertions.

Running and Evaluating Monitors

Monitors execute by polling the target system at a configured interval. The execution flow is:

  1. Resolve the target URL (via DNS, TLS, and connection handshake).
  2. Execute each step in order.
  3. For each step, record:
  1. Evaluate all assertions for the step.
  2. Aggregate results across all steps and compute summary metrics.

The monitor is considered successful if all steps pass and no assertions fail. If any step fails, the monitor is marked as failed. The outcome includes:

Failure modes are common and subtle:

Reusing and Composing Monitors

Synthetic monitors are most effective when composed into larger workflows. A monitor is not a single test but a building block.

Reusable Step Templates

Common sequences—like login, checkout, or API authentication—are reused across multiple monitors. A template is a named, parameterized set of steps.

{
  "name": "auth-flow",
  "parameters": ["username", "password"],
  "steps": [
    {
      "name": "Login Request",
      "method": "POST",
      "path": "/auth/login",
      "body": {
        "username": "{{username}}",
        "password": "{{password}}"
      },
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.token", "required": true }
      ]
    },
    {
      "name": "Set Auth Header",
      "action": "set",
      "key": "Authorization",
      "value": "Bearer {{token}}"
    }
  ]
}

This template can be instantiated in a monitor with specific values:

{
  "id": "checkout-flow",
  "steps": [
    { "template": "auth-flow", "username": "[email protected]", "password": "pass123" },
    { "name": "Add to Cart", "method": "POST", "path": "/cart", "body": { "item": "laptop" } },
    { "name": "Checkout", "method": "POST", "path": "/checkout" }
  ]
}

This allows consistent behavior across services and reduces configuration duplication.

Configuring Alerting and Response

Synthetic monitors produce metrics that trigger alerts. The alerting logic is defined by thresholds over time.

Thresholds

A threshold is a condition on a metric that, when met for a specified duration, triggers an alert. Metrics include:

Thresholds are evaluated on every execution and stored as time-series data.

Example: Latency Alert

{
  "metric": "latency",
  "condition": "avg > 1.0s",
  "duration": "3 consecutive runs",
  "window": "last 15m"
}

This means: if the average latency over the last 15 minutes is above 1 second, and this condition holds for three consecutive runs, an alert is fired.

Alerting States

Each monitor maintains a state: passing, failing, critical, suspended.

The state transitions are driven by a simple finite state machine. The monitor logs state changes:

[2023-10-05T12:00:00Z] monitor api-login-flow: state → failing (latency > 1.0s)
[2023-10-05T12:05:00Z] monitor api-login-flow: state → critical (latency > 1.0s for 3 runs)
[2023-10-05T12:15:00Z] monitor api-login-flow: state → passing (latency ≤ 1.0s for 3 runs)

Alert Notifications

When an alert is triggered, the system sends notifications via configured channels.

Email Notification

Subject: [Alert] api-login-flow: Latency > 1.0s (Critical)

Body:
Monitor: api-login-flow
Status: Critical
Duration: 3 consecutive runs
Average Latency: 1.32s
Last Run: 2023-10-05T12:10:30Z
Failed Steps:
  - Submit Login: 2.1s (expected ≤ 1.0s)
  - Fetch Dashboard: 1.8s (expected ≤ 1.0s)

Response Body (Submit Login):
{
  "user": {
    "id": 42,
    "name": "Alice"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Webhook Payload

{
  "monitor": "api-login-flow",
  "state": "critical",
  "timestamp": "2023-10-05T12:10:30Z",
  "latency": {
    "avg": 1.32,
    "max": 2.14,
    "min": 1.01,
    "steps": [
      { "name": "Fetch Login Page", "latency": 0.34 },
      { "name": "Submit Login", "latency": 2.14 },
      { "name": "Fetch Dashboard", "latency": 1.80 }
    ]
  },
  "failures": [
    {
      "step": "Submit Login",
      "status_code": 500,
      "message": "Internal Server Error",
      "response_body": "{\"error\":\"database_timeout\",\"details\":\"query took 2.5s\"}"
    }
  ]
}

Diagnosing and Debugging Synthetic Failures

Synthetic monitoring is only effective when failures are actionable.

Common Silent Failures

Debugging Patterns

To diagnose a synthetic failure, use the full execution trace:

  Step 1: Fetch Login Page
    Request:
      GET /login
      Host: api.example.com
      User-Agent: synthetic-monitor/1.2
    Response:
      200 OK
      Content-Type: application/json
      Body: {"csrf_token": "abc123", "title": "Login"}
      Duration: 0.23s

  Step 2: Submit Login
    Request:
      POST /login
      Host: api.example.com
      Authorization: Bearer abc123
      Content-Type: application/json
      Body: {"username": "admin", "password": "secret"}
    Response:
      500 Internal Server Error
      Content-Type: application/json
      Body: {"error": "database_timeout", "details": "query took 2.5s"}
      Duration: 2.14s
    assertion failed: $.user.id is missing (expected: number, actual: null)

Retrying and Fallbacks

When a monitor fails, the system may retry the execution:

Monitoring the Monitor Itself

Synthetic monitors are not immune to failure. To ensure reliability, monitor the monitors.

Self-Validation

A monitor can validate its own health:

Health Check Monitor

{
  "id": "monitor-health",
  "name": "Self-Health of Synthetic Monitors",
  "schedule": "every 15m",
  "steps": [
    {
      "name": "Fetch Monitor Config",
      "method": "GET",
      "path": "/api/v1/monitors/api-login-flow",
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.schedule", "value": "every 5m" },
        { "type": "json", "path": "$.steps[0].name", "value": "Fetch Login Page" },
        { "type": "json", "path": "$.alerting.thresholds[0].condition", "value": "avg > 1.0s" }
      ]
    },
    {
      "name": "Check Last 3 Runs",
      "method": "GET",
      "path": "/api/v1/monitors/api-login-flow/runs?limit=3",
      "expected_status": 200,
      "assertions": [
        { "type": "json", "path": "$.length", "value": 3 },
        { "type": "json", "path": "$.[0].status", "value": "success" },
        { "type": "json", "path": "$.[1].latency", "value": 1.12 }
      ]
    }
  ]
}

This monitor ensures that the configuration for api-login-flow is correct and that the monitor is running as expected.

Summary

Synthetic monitoring patterns revolve around defining, executing, and alerting on repeatable, structured tests. The core unit is the monitor: a sequence of steps with assertions, timed, scheduled, and evaluated. Success depends on consistent configuration, correct data flow, and clear diagnostics. The pattern is portable: any system that can execute HTTP requests, evaluate JSON, and send alerts can implement it. The sharp edges—timing, header casing, assertion path errors, and state transitions—are where synthetic monitoring delivers its greatest value: catching failures before users do.

This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.