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.
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:
api-login-flow)GET /login, POST /login, GET /dashboard)every 5m)30s)status_code == 200, response.body contains "Welcome")latency > 1s for 3 consecutive runs)The monitor is defined as a configuration object, typically in JSON or YAML, and deployed as a unit to a synthetic monitoring platform.
{
"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.
Monitors execute by polling the target system at a configured interval. The execution flow is:
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:
step_name: timeout after 30s.expected 200, got 503.$.user.id is missing or has wrong type. The error is assertion failed: $.user.id is missing.token from step 2 is used in step 3). If the token is not passed correctly, the monitor fails silently unless explicitly asserted.Synthetic monitors are most effective when composed into larger workflows. A monitor is not a single test but a building block.
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.
Synthetic monitors produce metrics that trigger alerts. The alerting logic is defined by thresholds over time.
A threshold is a condition on a metric that, when met for a specified duration, triggers an alert. Metrics include:
latency: total execution time of the monitorstep_latency: time taken for a single stepstatus_code: HTTP status returned by a stepassertion_failure: count of failed assertionsstep_failure: number of failed stepsThresholds are evaluated on every execution and stored as time-series data.
{
"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.
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)
When an alert is triggered, the system sends notifications via configured channels.
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..."
}
{
"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\"}"
}
]
}
Synthetic monitoring is only effective when failures are actionable.
Authorization: Bearer <token>, but the header is authorization: Bearer <token> (lowercase). The monitor runs, but the API returns 401, and no error is logged.{{token}}), but the template does not define set action, so the token is not propagated.ISO8601 timestamps, and the now() function in the step uses local time.application/x-www-form-urlencoded. The monitor succeeds, but the API returns 400 Bad Request with no additional diagnostics.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
$.user.id is missing, the monitor logs: assertion failed: $.user.id is missing (expected: number, actual: null)
When a monitor fails, the system may retry the execution:
health-check) to isolate the issue.Synthetic monitors are not immune to failure. To ensure reliability, monitor the monitors.
A monitor can validate its own health:
latency is within bounds, and that its assertions pass.{
"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.
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.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy