Production-grade guide to synthetic monitoring setup covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.
Synthetic monitoring setup is the process of defining, deploying, and maintaining automated, repeatable tests that simulate real user interactions with a system—typically HTTP requests, browser actions, or API calls—run from external locations against live services. It matters most when you need to guarantee service health proactively, detect regressions before users notice, and correlate downtime across services with consistent, synthetic signals. This setup is essential during rollouts, in distributed systems, and when building a resilient observability foundation.
A synthetic test begins with a clear definition of the user journey or service contract to validate. This includes the sequence of actions, expected responses, and thresholds for success.
Each test is a self-contained script that can be versioned, executed, and shared. Tests are typically defined in a standard, portable format—JSON, YAML, or a simple DSL.
name: "User checkout flow"
description: "Simulate a complete user purchase: add item, update cart, apply coupon, checkout"
type: "http"
locations:
- "us-east-1"
- "eu-west-1"
- "ap-southeast-2"
interval: 5m
timeout: 30s
retries: 2
steps:
- name: "Get product"
request:
method: GET
url: "https://api.example.com/products/123"
headers:
Accept: "application/json"
assertions:
- "status_code == 200"
- "json.path($..name).value == 'Wireless Headphones'"
- "json.path($..price).value > 50"
- name: "Add to cart"
request:
method: POST
url: "https://api.example.com/cart"
body:
product_id: 123
quantity: 2
headers:
Content-Type: "application/json"
assertions:
- "status_code == 201"
- "json.path($..total).value == 110"
- name: "Apply coupon"
request:
method: POST
url: "https://api.example.com/coupons/SAVE10"
assertions:
- "status_code == 200"
- "json.path($..discount).value == 10"
- name: "Finalize checkout"
request:
method: POST
url: "https://api.example.com/checkout"
body:
payment_method: "credit_card"
shipping_address: "123 Main St, Anytown"
assertions:
- "status_code == 200"
- "json.path($..order_id).exists"
- "json.path($..total).value == 100"
Tests are stored in version control. A test-checkout.yaml file is checked into tests/ in the repository. The test metadata—name, interval, locations—defines not only *what* to test, but *where* and *how often*.
Once defined, tests must be deployed to a monitoring system that executes them. Deployment involves registering the test with a scheduler and ensuring the test is available at runtime.
The deployment process is a two-step procedure: first, upload the test to a central registry, then configure the execution engine to pick it up.
# Register a test using a CLI tool
$ monitor deploy --file tests/test-checkout.yaml --name "checkout-flow"
This command sends a POST /tests request with the test body to a monitoring backend:
POST /tests
Host: monitoring.example.com
Authorization: Bearer abc123
Content-Type: application/json
{
"name": "checkout-flow",
"source": "git://github.com/example/ecommerce.git#tests/test-checkout.yaml",
"interval": "5m",
"timeout": 30,
"retries": 2,
"locations": [
"us-east-1",
"eu-west-1",
"ap-southeast-2"
],
"steps": [ ... ]
}
The backend persists the test and assigns it a unique ID. The scheduler picks up the test and begins executing it every five minutes from the specified locations.
Locations define where the test runs. They are typically geographic endpoints with known network characteristics.
Locations are pre-configured in the system and referenced by name. Each location may have its own network profile: latency, bandwidth, and DNS resolver.
{
"name": "us-east-1",
"region": "us-east-1",
"latency": {
"average": 60,
"standard_deviation": 15
},
"dns": "1.1.1.1",
"proxy": "https://proxy-us.example.com",
"time_zone": "America/New_York"
}
Location names are used in the test definition and resolved at runtime. If a location is unavailable, the test runs from the next available one with a fallback policy.
A test execution begins with a test_run entry in the database:
INSERT INTO test_runs (
test_id,
location,
started_at,
status
) VALUES (
't-abc123',
'eu-west-1',
'2024-08-15T10:00:00Z',
'running'
);
The execution engine pulls the test, resolves all step dependencies, and executes each step in order. Steps are executed via HTTP clients, with timeouts, retries, and error handling.
Each step is an HTTP request with optional assertions. Assertions are evaluated after the request completes.
{
"step_id": "step-01",
"test_run_id": "run-xyz789",
"name": "Get product",
"request": {
"method": "GET",
"url": "https://api.example.com/products/123",
"headers": {
"Accept": "application/json"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json",
"Cache-Control": "max-age=300"
},
"body": {
"id": 123,
"name": "Wireless Headphones",
"price": 59.99,
"in_stock": true
},
"duration_ms": 42
},
"assertions": [
{
"name": "status_code == 200",
"passed": true,
"error": null
},
{
"name": "json.path($..name).value == 'Wireless Headphones'",
"passed": true,
"error": null
},
{
"name": "json.path($..price).value > 50",
"passed": true,
"error": null
}
]
}
Assertions are evaluated using a simple expression language. Expressions can compare values, extract JSON fields, or evaluate conditions.
Common assertion types:
status_code == 200json.path($..name).value == 'Wireless Headphones'response.headers['Content-Type'] == 'application/json'json.path($..items).length > 0response.body.total > 100duration_ms < 500Assertions fail if any condition evaluates to false. The first failed assertion is recorded in the test run.
After execution, the test run data is used to trigger alerts and generate metrics.
Alerts are defined by thresholds on test run metrics: duration, success rate, error rate, and availability.
# alerts.yaml
name: "Checkout flow alert"
description: "Notify on 3 consecutive failures in checkout flow"
condition:
test: "checkout-flow"
metric: "success_rate"
window: "1h"
threshold: 0.95
trigger: "below"
min_occurrences: 3
consecutive: true
actions:
- "email"
- "webhook"
- "slack"
- "pagerduty"
This configuration triggers an alert when the success rate of the checkout flow drops below 95% over a one-hour window, with at least three consecutive failures.
When a test run fails, the system records the failure reason, and the test run is marked as failed.
{
"test_run_id": "run-xyz789",
"status": "failed",
"failure_reason": "One or more assertions failed",
"error_details": [
{
"step_id": "step-03",
"assertion": "json.path($..discount).value == 10",
"expected": 10,
"actual": 8,
"message": "Coupon discount was 8, expected 10"
},
{
"step_id": "step-04",
"assertion": "json.path($..total).value == 100",
"expected": 100,
"actual": 105,
"message": "Final total is 105, expected 100"
}
],
"timestamp": "2024-08-15T10:05:32Z"
}
The failure details are available in the monitoring UI and used for alert deduplication and correlation.
Failures are not just logs—they are actionable events. The system must detect, classify, and escalate them.
The most common silent failure is a test that passes with no errors but has a high duration.
{
"test_run_id": "run-xyz789",
"duration_ms": 4200,
"status": "warning",
"warning_reason": "Duration exceeds 3000ms",
"threshold": 3000
}
Such tests are often slow due to backend latency, cache misses, or database load, but the test does not fail the assertion criteria.
When a test step fails, the system retries it up to the configured number of times.
Each retry is logged with a separate response and assertion result.
{
"step_id": "step-02",
"retries": 2,
"attempts": [
{
"attempt": 1,
"status": "failed",
"response": {
"status": 504,
"body": { "error": "Gateway Timeout" }
},
"assertions": [
{ "name": "status_code == 201", "passed": false }
]
},
{
"attempt": 2,
"status": "succeeded",
"response": {
"status": 201,
"body": { "id": 456, "total": 110 }
},
"assertions": [
{ "name": "status_code == 201", "passed": true }
]
}
]
}
The system records the full retry history and marks the step as successful if any attempt passed.
Each test run includes metadata that is critical for debugging.
{
"test_run_id": "run-xyz789",
"test_name": "checkout-flow",
"location": "eu-west-1",
"started_at": "2024-08-15T10:00:00Z",
"finished_at": "2024-08-15T10:05:32Z",
"duration_ms": 3320,
"status": "failed",
"environment": {
"version": "v2.1.3",
"commit": "abc123def456",
"branch": "main"
},
"execution_context": {
"agent_version": "1.8.2",
"network_profile": "latency=65ms, jitter=12ms",
"dns_resolution": [
{ "domain": "api.example.com", "ip": "192.0.2.1", "time_ms": 15 }
],
"timezone": "Europe/London"
}
}
This metadata is used to correlate synthetic results with logs, traces, and metrics.
As services evolve, tests must be maintained. A test suite is not static.
Tests are versioned in Git. When a test changes, the monitoring system detects the change and deploys it.
The system supports rolling out new test versions while keeping old ones active.
A test can be configured to run in multiple versions simultaneously:
test:
name: "checkout-flow"
versions:
- id: "v1",
source: "tests/[email protected]"
- id: "v2",
source: "tests/[email protected]"
default_version: "v2"
The system executes the default version and tracks metrics separately for each version.
Tests are discovered via a standard discovery mechanism: a directory of test files, or a registry endpoint.
GET /tests/discover
Accept: application/yaml
Authorization: Bearer abc123
Response:
- name: "checkout-flow"
source: "git://github.com/example/ecommerce.git#tests/test-checkout.yaml"
interval: "5m"
locations: ["us-east-1", "eu-west-1"]
- name: "login-flow"
source: "git://github.com/example/ecommerce.git#tests/test-login.yaml"
interval: "10m"
locations: ["us-west-1"]
The monitoring system periodically polls this endpoint and registers new tests.
interval field is not the frequency of execution, but the target interval. The system may run a test every 4m 50s instead of exactly 5m, based on load and scheduling.failure_kind field: timeout, assertion_failed, network_error, step_missing.Synthetic monitoring setup is not just about writing tests. It is about orchestrating their lifecycle: defining, deploying, executing, observing, alerting, and maintaining. It is the foundation for proactive observability, turning system health into measurable, repeatable, and actionable events.
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