Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install testing@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin testing v1.0.0 follows the Agent Plugins spec.
gh skills-hub install testing Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/testing/ Extract the ZIP to .github/skills/ in your repo. The folder name must match testing for Copilot to auto-discover it.
Skill Files (5)
SKILL.md 5.3 KB
---
name: testing
license: Apache-2.0
description: Probe, load-test, and instrument frontends from Grafana Cloud. Covers Synthetic Monitoring (HTTP / DNS / TCP / Ping / Traceroute / Multihttp / k6-browser scripted checks from 20+ global probes, alert on `probe_success` + TLS-cert expiry), Grafana Cloud k6 (distributed load tests across AWS load-zones, scenarios, `http_req_duration` thresholds, CI integration via `grafana/k6-action`), and Frontend Observability with Faro Web SDK (RUM, Core Web Vitals, custom events, `pushError`, distributed-trace correlation). Use when checking website / API uptime from multiple regions, gating a release on a load test, watching for TLS-cert renewal, instrumenting a React/Vue app, tracking Core Web Vitals, or correlating frontend errors to backend traces — even when the user says "is my login flow up?", "monitor my API", "ping our endpoint every minute", "release-gate load test", "browser performance monitoring", "session replay", or "RUM" without naming Synthetic Monitoring / k6 / Faro.
---
# Grafana Cloud Testing
> **Docs**: https://grafana.com/docs/grafana-cloud/testing/
Three pillars: external probing (Synthetic Monitoring), load testing (k6 Cloud), real-user monitoring (Faro).
## Prerequisites
- Grafana Cloud stack
- Synthetic Monitoring: SM access token (`sm:write`)
- k6 Cloud: a Grafana Cloud k6 token + projectID
- Faro: a Faro app + write-token from **Frontend Observability → Apps**
## Common Workflows
### 1. Create + verify a Synthetic HTTP check
```bash
# 1. Create the check (full payload in references/synthetic.md)
curl -X POST https://synthetic-monitoring-api.grafana.net/sm/checks \
-H "Authorization: Bearer <sm-token>" -H "Content-Type: application/json" \
-d '{"job":"website","target":"https://example.com","frequency":60000,"timeout":15000,
"enabled":true,"probes":[1,5,10],
"settings":{"http":{"method":"GET","validStatusCodes":[200]}}}'
# 2. List checks — confirm it exists and is enabled
curl -s https://synthetic-monitoring-api.grafana.net/sm/checks \
-H "Authorization: Bearer <sm-token>" | jq '.[] | select(.job=="website")'
# 3. Verify probe_success arrived (wait ~60s for the first run)
# In Grafana Explore on the synthetic metrics datasource:
# probe_success{job="website"}
# Expect 1 from each probe in `probes:[1,5,10]`.
#
# Rollback: DELETE /sm/checks/<id> or set `"enabled": false`.
```
See [`references/synthetic.md`](references/synthetic.md) for all check types, PromQL queries, and alert rules.
### 2. Run a k6 cloud load test
```bash
# 1. Authenticate once
k6 cloud login --token <grafana-cloud-k6-token>
# 2. Validate the script locally first (smoke run, no cloud cost)
k6 run --vus 1 --duration 30s script.js
# 3. Launch in cloud
k6 cloud script.js
# → URL of the run; thresholds (p95<500ms, error<1%) decide pass/fail.
# 4. Verify in CI — exit code 0 = thresholds passed, 99 = threshold failed.
echo $?
```
Full script + scenarios + CI YAML: [`references/k6-and-faro.md`](references/k6-and-faro.md).
### 3. Instrument a frontend with Faro
```bash
# 1. Install
npm install @grafana/faro-web-sdk @grafana/faro-web-tracing
```
```javascript
// 2. initializeFaro({ url, apiKey, app, instrumentations }) — see references/k6-and-faro.md
// 3. Push a test event so we have something to look for:
faro.api.pushEvent('faro_smoketest', { ts: Date.now().toString() });
```
```bash
# 4. Verify the collector accepted it (browser DevTools → Network)
# POST to /collect should return 202. If 401 — apiKey mismatch.
# 5. Verify in Grafana
# - Frontend Observability → your app → Sessions: should show your session
# - Explore on Loki: `{kind="event"} |= "faro_smoketest"`
# - For traces: filter by `service.name="my-frontend"` in Tempo
```
## Troubleshooting
- Synthetic check stuck at `probe_success=0` → check `probe_*_duration_seconds` for the failing stage; the probe-region label tells you which prober errored
- k6 cloud run "ABORTED_THRESHOLD" → a threshold tripped; inspect the run page to see which one
- Faro events not landing → check the browser network call to `/collect` returns 202; common cause is wrong `apiKey` or `url` (must match the FE Observability app)
## References
- For deep authoring of Synthetic Monitoring scripted (k6) and browser checks — execution model, assertions, secrets, API/Terraform payloads — see the [`synthetic-monitoring-checks`](../synthetic-monitoring-checks/SKILL.md) skill
- [`references/synthetic.md`](references/synthetic.md) — Synthetic Monitoring essentials: check types, key PromQL metrics, alert rules
- [`references/synthetic-monitoring.md`](references/synthetic-monitoring.md) — deep dive: full API for check CRUD, probe selection, scripted (k6) checks, multi-step browser checks
- [`references/k6-and-faro.md`](references/k6-and-faro.md) — k6 cloud script + Faro Web SDK init snippets for end-to-end testing
- [`references/k6-cloud.md`](references/k6-cloud.md) — deep dive: k6 cloud config (project + load zones + thresholds), CI integration, run analysis
## Resources
- [Synthetic Monitoring docs](https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/)
- [Grafana Cloud k6 docs](https://grafana.com/docs/grafana-cloud/testing/k6/)
- [Faro / Frontend Observability docs](https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/)
k6-and-faro.md 2.6 KB
# k6 Cloud + Faro RUM — full snippets
## k6 cloud script
```javascript
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
cloud: {
projectID: 3456789,
name: 'API Load Test - Release v2.0',
distribution: {
loadZone1: { loadZone: 'amazon:us:ashburn', percent: 50 },
loadZone2: { loadZone: 'amazon:eu:dublin', percent: 30 },
loadZone3: { loadZone: 'amazon:ap:tokyo', percent: 20 },
},
},
scenarios: {
load: {
executor: 'ramping-vus',
startVUs: 0,
stages: [
{ duration: '2m', target: 100 },
{ duration: '10m', target: 100 },
{ duration: '2m', target: 0 },
],
},
},
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://api.example.com/users');
check(res, {
'status 200': (r) => r.status === 200,
'fast': (r) => r.timings.duration < 500,
});
sleep(1);
}
```
## k6 Cloud commands
```bash
# Authenticate
k6 cloud login --token <your-grafana-cloud-token>
# Run in cloud
k6 cloud script.js
# Run locally, stream results to cloud
k6 run --out cloud script.js
```
## k6 Cloud API
```bash
# List test runs
curl https://api.k6.io/v3/projects/{projectId}/test-runs -H "Authorization: Token <token>"
# Get test run results
curl https://api.k6.io/v3/runs/{runId} -H "Authorization: Token <token>"
# Stop a running test
curl -X POST https://api.k6.io/v3/runs/{runId}/stop -H "Authorization: Token <token>"
```
## GitHub Actions
```yaml
- name: Run k6 Load Test
uses: grafana/k6-action@v0.3.1
with:
filename: tests/load.js
cloud: true
token: ${{ secrets.K6_CLOUD_TOKEN }}
flags: --out cloud
```
## Faro / Frontend Observability
```bash
npm install @grafana/faro-web-sdk @grafana/faro-web-tracing
```
```javascript
import { initializeFaro, getWebInstrumentations } from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
const faro = initializeFaro({
url: 'https://faro-collector-prod-xx.grafana.net/collect',
apiKey: 'your-faro-api-key',
app: { name: 'my-frontend', version: '1.0.0', environment: 'production' },
instrumentations: [
...getWebInstrumentations({ captureConsole: true, captureConsoleDisabledLevels: [] }),
new TracingInstrumentation(),
],
});
// Custom events / measurements / errors
faro.api.pushEvent('checkout_completed', { cart_value: '99.99' });
faro.api.pushMeasurement({ type: 'api_latency', values: { ms: 234 } });
faro.api.pushError(new Error('Payment failed'));
```
k6-cloud.md 4.8 KB
# k6 Cloud Reference
## Authentication
```bash
# Via token
k6 cloud login --token <your-grafana-cloud-token>
# Via environment variable
export K6_CLOUD_TOKEN=<your-token>
# Verify
k6 cloud login --show
```
## Run Commands
```bash
# Run in cloud (full cloud execution)
k6 cloud script.js
# Run locally, stream results to cloud
k6 run --out cloud script.js
# Run with environment variables
k6 cloud -e API_URL=https://api.example.com script.js
# Run with specific project
k6 cloud --project-id 123456 script.js
# Local execution (run on cloud infra but with local VUs)
k6 cloud run --local-execution script.js
```
## options.cloud Reference
```javascript
export const options = {
cloud: {
// Required
projectID: 3456789,
// Optional
name: 'API Load Test - Release v2.0',
note: 'Testing new checkout flow',
// Load zone distribution
distribution: {
loadZone1: { loadZone: 'amazon:us:ashburn', percent: 40 },
loadZone2: { loadZone: 'amazon:us:portland', percent: 20 },
loadZone3: { loadZone: 'amazon:eu:dublin', percent: 20 },
loadZone4: { loadZone: 'amazon:ap:singapore', percent: 20 },
},
// Static IPs (Enterprise)
staticIPs: false,
},
};
```
## Load Zones
### Americas
| Zone ID | Location |
|---------|----------|
| `amazon:us:ashburn` | Ashburn, Virginia, USA |
| `amazon:us:columbus` | Columbus, Ohio, USA |
| `amazon:us:portland` | Portland, Oregon, USA |
| `amazon:us:montreal` | Montréal, Canada |
| `amazon:sa:sao paulo` | São Paulo, Brazil |
### Europe
| Zone ID | Location |
|---------|----------|
| `amazon:eu:dublin` | Dublin, Ireland |
| `amazon:eu:frankfurt` | Frankfurt, Germany |
| `amazon:eu:london` | London, UK |
| `amazon:eu:paris` | Paris, France |
| `amazon:eu:stockholm` | Stockholm, Sweden |
| `amazon:eu:milan` | Milan, Italy |
### Asia Pacific
| Zone ID | Location |
|---------|----------|
| `amazon:ap:singapore` | Singapore |
| `amazon:ap:sydney` | Sydney, Australia |
| `amazon:ap:tokyo` | Tokyo, Japan |
| `amazon:ap:mumbai` | Mumbai, India |
| `amazon:ap:seoul` | Seoul, South Korea |
| `amazon:ap:hong kong` | Hong Kong |
| `amazon:ap:osaka` | Osaka, Japan |
| `amazon:ap:jakarta` | Jakarta, Indonesia |
| `amazon:ap:cape town` | Cape Town, South Africa |
| `amazon:me:bahrain` | Bahrain |
## CI/CD Integration
### GitHub Actions
```yaml
- name: Run k6 Cloud Test
uses: grafana/k6-action@v0.3.1
with:
filename: tests/load.js
cloud: true
token: ${{ secrets.K6_CLOUD_TOKEN }}
```
### GitLab CI
```yaml
k6-cloud:
image: grafana/k6
script:
- k6 cloud login --token $K6_CLOUD_TOKEN
- k6 cloud tests/load.js
only:
- main
```
### CircleCI
```yaml
- run:
name: Run k6 Cloud Test
command: |
k6 cloud login --token $K6_CLOUD_TOKEN
k6 cloud tests/load.js
```
## REST API
```bash
BASE=https://api.k6.io/v3
TOKEN=your-token
# List projects
curl $BASE/projects -H "Authorization: Token $TOKEN"
# List test runs for a project
curl "$BASE/projects/{projectId}/test-runs" -H "Authorization: Token $TOKEN"
# Get test run details + results
curl "$BASE/runs/{runId}" -H "Authorization: Token $TOKEN"
# Get metrics for a run
curl "$BASE/runs/{runId}/metrics" -H "Authorization: Token $TOKEN"
# Stop a running test
curl -X POST "$BASE/runs/{runId}/stop" -H "Authorization: Token $TOKEN"
# Create a scheduled test
curl -X POST "$BASE/projects/{projectId}/schedules" \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Nightly load test",
"script_id": 123,
"cron": "0 2 * * *",
"timezone": "UTC"
}'
```
## Test Authoring Tools
- **k6 Studio** — desktop GUI for recording, building, and running k6 tests
- **Browser recorder** — Chrome extension that records user journeys as k6 scripts
- **Test builder** — drag-and-drop scenario builder in Grafana Cloud UI (no code required)
- **k6 TypeScript template** — starter template with TypeScript support and type definitions
## Result Analysis
```bash
# View results summary after cloud run
k6 cloud --results-id {runId}
# Export results as JSON
k6 cloud --results-export results.json
```
In the Cloud UI:
- **Performance Overview**: VUs, request rate, error rate, response time over time
- **Checks tab**: pass/fail rates per check, by time
- **Thresholds**: pass/fail status for each threshold
- **Logs tab**: console.log output from VUs
- **Comparison**: overlay multiple test runs to spot regressions
## When to Use Each Tool
| Scenario | Use |
|----------|-----|
| External uptime monitoring, always-on | Synthetic Monitoring |
| Scheduled lightweight API health checks | Synthetic Monitoring |
| Load testing before a release | k6 Cloud |
| Stress testing to find limits | k6 Cloud |
| Performance regression in CI/CD | k6 Cloud |
| Real user monitoring (browser) | Faro / Frontend Observability |
synthetic-monitoring.md 4.6 KB
# Synthetic Monitoring Reference
## Check Types
| Type | Protocol | Use Case |
|------|----------|----------|
| **HTTP** | HTTP/HTTPS | Website/API uptime and response validation |
| **DNS** | DNS | Record resolution and lookup time |
| **TCP** | TCP | Port/service reachability |
| **Ping** | ICMP | Host availability |
| **MultiHTTP** | HTTP/HTTPS | Multi-step API flows (login, then action) |
| **Browser** (k6) | Chrome | Full browser page load, Core Web Vitals |
| **Scripted** (k6) | k6 script | Custom JS test logic |
## HTTP Check Fields
```json
{
"job": "api-health",
"target": "https://api.example.com/health",
"frequency": 60000,
"timeout": 15000,
"enabled": true,
"probes": [1, 2, 5, 10, 14],
"settings": {
"http": {
"method": "GET",
"ipVersion": "V4",
"noFollowRedirects": false,
"tlsConfig": {
"insecureSkipVerify": false,
"serverName": "api.example.com"
},
"validStatusCodes": [200],
"validHTTPVersions": ["HTTP/1.1", "HTTP/2.0"],
"failIfBodyMatchesRegexp": ["error", "exception"],
"failIfBodyNotMatchesRegexp": [],
"failIfHeaderMatchesRegexp": [],
"failIfHeaderNotMatchesRegexp": [],
"headers": [
{"name": "Authorization", "value": "Bearer token"},
{"name": "User-Agent", "value": "Grafana-SM/1.0"}
],
"body": "",
"bearerToken": "",
"basicAuth": {"username": "", "password": ""}
}
},
"labels": [{"name": "env", "value": "production"}],
"alertSensitivity": "medium"
}
```
## Probe Locations (Post Feb 2025 AWS Migration)
### Americas (AMER)
| ID | Location |
|----|----------|
| 1 | Columbus, Ohio, USA (AWS us-east-2) |
| 2 | Manassas, Virginia, USA (AWS us-east-1) |
| 14 | Portland, Oregon, USA (AWS us-west-2) |
| 15 | São Paulo, Brazil (AWS sa-east-1) |
| 16 | Montreal, Canada (AWS ca-central-1) |
### Europe, Middle East, Africa (EMEA)
| ID | Location |
|----|----------|
| 5 | Frankfurt, Germany (AWS eu-central-1) |
| 10 | Dublin, Ireland (AWS eu-west-1) |
| 17 | London, UK (AWS eu-west-2) |
| 18 | Paris, France (AWS eu-west-3) |
| 19 | Stockholm, Sweden (AWS eu-north-1) |
| 20 | Milan, Italy (AWS eu-south-1) |
| 21 | Cape Town, South Africa (AWS af-south-1) |
| 22 | Bahrain (AWS me-south-1) |
### Asia Pacific (APAC)
| ID | Location |
|----|----------|
| 3 | Singapore (AWS ap-southeast-1) |
| 4 | Sydney, Australia (AWS ap-southeast-2) |
| 6 | Tokyo, Japan (AWS ap-northeast-1) |
| 7 | Mumbai, India (AWS ap-south-1) |
| 8 | Seoul, South Korea (AWS ap-northeast-2) |
| 9 | Hong Kong (AWS ap-east-1) |
| 11 | Osaka, Japan (AWS ap-northeast-3) |
| 12 | Jakarta, Indonesia (AWS ap-southeast-3) |
| 13 | Melbourne, Australia (AWS ap-southeast-4) |
## Alert Sensitivity Levels
| Level | Probe Success Threshold | For Duration |
|-------|------------------------|--------------|
| `none` | No alerts | - |
| `low` | < 50% probes succeeding | 5 minutes |
| `medium` | < 75% probes succeeding | 5 minutes |
| `high` | < 95% probes succeeding | 5 minutes |
Custom alert override (per-check):
```yaml
# Override per check in Terraform
resource "grafana_synthetic_monitoring_check" "api" {
...
alert_sensitivity = "high"
}
```
## Terraform (Configuration as Code)
```hcl
terraform {
required_providers {
grafana = { source = "grafana/grafana" }
}
}
provider "grafana" {
sm_access_token = var.sm_access_token
sm_url = "https://synthetic-monitoring-api.grafana.net"
}
resource "grafana_synthetic_monitoring_check" "website" {
job = "homepage"
target = "https://example.com"
enabled = true
frequency = 60000
timeout = 15000
probes = [1, 5, 10, 14]
settings {
http {
valid_status_codes = [200]
valid_http_versions = ["HTTP/1.1", "HTTP/2.0"]
}
}
labels = {
environment = "production"
team = "platform"
}
}
```
## Grizzly (YAML as Code)
```yaml
apiVersion: grizzly.grafana.com/v1alpha1
kind: SyntheticMonitoringCheck
metadata:
name: api-health
spec:
job: api-health
target: https://api.example.com/health
frequency: 60000
timeout: 10000
probes: [1, 5, 10]
settings:
http:
method: GET
validStatusCodes: [200]
```
## Key Metrics
```promql
# Uptime % over 7 days
avg_over_time(probe_success{job="api-health"}[7d]) * 100
# P95 response time by location
histogram_quantile(0.95,
sum(rate(probe_duration_seconds_bucket{job="api-health"}[5m])) by (le, probe)
)
# DNS lookup time trend
avg(probe_dns_lookup_time_seconds{job="dns-check"}) by (probe)
# TLS certificate days until expiry
(probe_ssl_earliest_cert_expiry{job="api-health"} - time()) / 86400
# Availability by region
avg(probe_success{job="api-health"}) by (probe)
```
synthetic.md 2.2 KB
# Synthetic Monitoring — check types, metrics, alerts
## Check types
| Check | Use case |
|-------|----------|
| **HTTP** | Website / API availability, response validation |
| **DNS** | DNS resolution time + record validation |
| **TCP** | Port / service connectivity |
| **Ping** | ICMP availability |
| **Traceroute** | Network path diagnostics |
| **Multihttp** | Multi-step HTTP flows |
| **Scripted** (k6 browser) | Full browser-based user-flow testing |
## HTTP check (full API payload)
```bash
curl -X POST https://synthetic-monitoring-api.grafana.net/sm/checks \
-H "Authorization: Bearer <sm-access-token>" \
-H "Content-Type: application/json" \
-d '{
"job": "website",
"target": "https://example.com",
"frequency": 60000,
"timeout": 15000,
"enabled": true,
"probes": [1, 5, 10],
"settings": {
"http": {
"method": "GET",
"ipVersion": "V4",
"noFollowRedirects": false,
"tlsConfig": {},
"validStatusCodes": [200, 201],
"validHTTPVersions": ["HTTP/1.1", "HTTP/2.0"],
"failIfBodyMatchesRegexp": ["error", "exception"],
"failIfBodyNotMatchesRegexp": ["OK"],
"headers": [{"name": "User-Agent", "value": "Grafana-Synthetic-Monitoring"}]
}
}
}'
```
## Useful PromQL
```promql
# Probe success rate
sum(rate(probe_success[5m])) by (job, instance, probe)
# HTTP response time p95
histogram_quantile(0.95, sum(rate(probe_duration_seconds_bucket[5m])) by (le, job))
# DNS lookup time
avg(probe_dns_lookup_time_seconds) by (job, instance)
# TLS expiry days remaining
(probe_ssl_earliest_cert_expiry - time()) / 86400
```
## Alert rules
```yaml
groups:
- name: synthetic-monitoring
rules:
- alert: SyntheticCheckFailing
expr: avg_over_time(probe_success[5m]) < 0.9
for: 5m
labels: { severity: critical }
annotations:
summary: "{{ $labels.job }} failing from {{ $labels.probe }}"
- alert: TLSCertExpiringSoon
expr: (probe_ssl_earliest_cert_expiry - time()) / 86400 < 14
labels: { severity: warning }
annotations:
summary: "TLS cert for {{ $labels.instance }} expires in {{ $value }} days"
```
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/grafana/skills/blob/main/LICENSE