Loading...
Loading...
Author Grafana Cloud Synthetic Monitoring checks, with deep coverage of k6 scripted and browser checks: SM's single-VU/single-iteration execution model, assertions that actually fail probe_success (expect() and fail() vs bare check()), secrets, deterministic scripts, robust browser locators, local validation with k6 run, deployment via UI/API/Terraform, verifying probe_success, and rollback. Also helps choose the simplest sufficient check type (HTTP/ping/DNS/TCP, MultiHTTP, scripted, browser). Use when writing a synthetic check, monitoring a login/checkout/signup flow in production, converting a k6 script or an OpenAPI spec into a check, authoring a browser check, validating a user journey, or asking "is my site up from multiple regions". NOT for load, stress, or performance testing — SM runs one iteration per execution; for load tests use the grafana-k6 plugin or Grafana Cloud k6. For the broad Grafana Cloud Testing overview (SM + k6 Cloud + Faro), use the testing skill.
npx skill4agent add grafana/skills synthetic-monitoring-checksDocs: https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/ Broad Grafana Cloud Testing entry point (SM + k6 Cloud + Faro):skill.testing
stagesthresholdsgrafana-k6k6| Constraint | Value |
|---|---|
| Workload | One iteration per probe execution. Scripted and MultiHTTP run with forced |
| Not supported |
| Frequency | k6-class checks (scripted, MultiHTTP, browser): 60–3600s. Protocol checks (HTTP/ping/DNS/TCP/gRPC): 1–3600s. Traceroute: 120–3600s |
| Timeout | Must be ≤ frequency. k6-class checks: 1–180s. Protocol checks: 1–60s. Traceroute: fixed 30s |
| k6 version | Checks run on a k6 version channel (new checks default to the latest stable channel; |
| Local files | |
| HTTP request errors | SM runs k6 with |
| Script options SM honors | SM sets its own CLI flags, which take precedence over the script's |
| Browser memory | 1GB RAM per browser on public probes — huge pages fail with |
| Browser script format | The UI rejects bundled/minified browser scripts (import validation) — deploy those via API or Terraform |
probe_successfail()expect()test.abort()--throwcheck()probe_checks_totalprobe_check_success_rateimport { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';
import { check, fail } from 'k6';
// 1. PREFERRED — assertions module. Throws on failure => execution fails,
// with a descriptive error in the check logs.
expect(res.status, 'login should succeed').toEqual(200);
expect(res.json('token')).toBeDefined();
// 2. Soft assertions — run all of them, still fail the execution at the end.
expect.soft(res.headers['Content-Type']).toContain('application/json');
// 3. check() when you also want per-assertion metrics — but pair it with
// fail() or the failure won't affect probe_success/uptime:
check(res, { 'status 200': (r) => r.status === 200 }) ||
fail(`login failed with status ${res.status}`);checkprobe_checks_totaltargetreferences/api-and-terraform.md${variable}probes × duration_minutes × (43200 / frequency_minutes)Generated by synthetic-monitoring-checksdate -u +%Y-%m-%dT%H:%M:%SZ// Generated by synthetic-monitoring-checks (https://github.com/grafana/skills) on 2026-07-31T12:00:00Z
import http from 'k6/http';
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';
import secrets from 'k6/secrets';
const BASE = 'https://api.example.com';
export default async function () {
// Secrets are managed in Synthetics > Config > Secrets — never hardcode credentials.
const password = await secrets.get('checkout-monitor-password');
// Step 1: authenticate with a dedicated monitoring account
const login = http.post(
`${BASE}/auth/login`,
JSON.stringify({ user: 'sm-checkout-monitor', password }),
{ headers: { 'Content-Type': 'application/json' } }
);
expect(login.status, 'login should return 200').toEqual(200);
const token = login.json('token');
expect(token, 'auth token should be present').toBeDefined();
// Step 2: exercise the journey and assert the OUTCOME, not just the status
const order = http.post(`${BASE}/orders`, JSON.stringify({ sku: 'TEST-SKU-1', qty: 1 }), {
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
});
expect(order.status, 'order should be created').toEqual(201);
const orderId = order.json('id');
expect(orderId, 'order id should be returned').toBeDefined();
// Step 3: clean up so the check is idempotent against production
// http.url groups metrics for URLs containing unique IDs — without it, every
// execution creates new time series (cardinality + active-series cost).
const del = http.del(http.url`${BASE}/orders/${orderId}`, null, {
headers: { Authorization: `Bearer ${token}` },
});
expect(del.status, 'test order should be cleaned up').toEqual(204);
}http.urlPOSTPUTDELETEexpect(order.json('id'), 'id required by OrdersResponse schema').toBeDefined()servers:securitySchemessecrets.get()format: int64res.json('id')const id = (/"id":\s*(\d+)/.exec(res.body) || [])[1];curl/api/*k6/browserchromium// Generated by synthetic-monitoring-checks (https://github.com/grafana/skills) on 2026-07-31T12:00:00Z
import { browser } from 'k6/browser';
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';
import secrets from 'k6/secrets';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: { browser: { type: 'chromium' } },
},
},
};
export default async function () {
const page = await browser.newPage();
try {
await page.goto('https://shop.example.com/login');
// Prefer role/label/test-id locators over CSS chains — they survive redesigns.
const password = await secrets.get('shop-monitor-password');
await page.getByLabel('Email').fill('sm-monitor@example.com');
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign in' }).click();
// Assert the JOURNEY OUTCOME with auto-retrying assertions — never sleep().
await expect(page.getByRole('heading', { name: 'Your account' })).toBeVisible();
await page.getByRole('link', { name: 'Orders' }).click();
await expect(page.getByTestId('order-list')).toBeVisible();
} finally {
await page.close();
}
}getByRolegetByLabelgetByTestIddata-testidgetByTestIddata-testiddata-cypage.locator('[data-cy="..."]')waitFor()click()fill()waitForLoadState()sleep()expect()toBeVisibletoBeEnabledtoHaveTexttoContainTextawait expect(page.getByText('Order confirmed')).toBeVisible()const expectUi = expect.configure({ timeout: 20000 });try/finallypage.close()page.screenshot()probe_browser_web_vital_lcp|cls|fcp|inp|ttfbk6 run script.js # scripted check
K6_BROWSER_HEADLESS=true k6 run browser-check.js # browser check
k6 run --secret-source=mock=checkout-monitor-password=example-password script.js # with secrets
# Many/large secrets: k6 run --secret-source=file=secrets.txt script.jsreferences/api-and-terraform.mdfrequencytimeoutsettings.scripted.scriptsettings.browser.scriptfile()# 1 from every selected probe = healthy
probe_success{job="checkout-flow"}
# Assertion pass rate per named assertion (scripted/browser)
probe_check_success_rate{job="checkout-flow"}
# Journey duration per probe — confirm it's comfortably under the timeout
probe_script_duration_seconds{job="checkout-flow"}
# Uptime over time (how the SM app computes it)
max by () (max_over_time(probe_success{job="checkout-flow"}[5m]))probe_success == 1probe_check_success_rateprobe_browser_web_vital_*enabled: falsealertSensitivityprobe_successtesting| Symptom | Cause → fix |
|---|---|
| Passes locally, fails on all probes | Target not reachable from the public internet (internal DNS, VPN, IP allowlist). Use private probes for internal targets, or allowlist probe egress |
| Passes locally, fails on some probes | Geo-blocking, regional CDN/WAF rules, or bot protection challenging datacenter IPs. Check |
Check "fails" in your eyes but | Bare |
| Browser check flaps with locator timeouts | Brittle selectors or animation timing. Switch to |
| The locator matches multiple elements (strict mode) — the error message is misleading. Tighten the selector or use |
| Create succeeds but readback 404s on every execution | The id exceeds |
| Secret name mismatch (names are exact, ≤253 chars, letters/numbers/ |
| Executions time out but the journey is fine | Timeout too low for the journey (max 180s) — raise it; or the script does unbounded work per iteration. Also confirm timeout < frequency |
| Page exceeds the 1GB probe browser memory — trim the journey, block heavy third-party resources, or use a private probe with more memory |
| UI rejects a browser script | Bundled/minified script fails the UI's import validation — create it via API or Terraform instead |
| Metrics/billing explosion after adding a check | Unique IDs in URLs creating per-execution time series — use |
references/api-and-terraform.mdexpectgrafana-k6k6