Loading...
Loading...
Investigate a Grafana Cloud k6 test — describe the script, list run history, identify pass/fail status, pull raw metric time-series and log lines for one or more runs, and (if asked) safely edit the test script. Use when the user asks about a specific k6 cloud test or run, gives a `/a/k6-app/tests/<id>` or `/a/k6-app/runs/<id>` URL, asks "is this test passing", "why are my k6 tests failing", "show me metrics for run X", "show me logs for run X", or wants to add thresholds / fix a failing test. Trigger this skill even when the user doesn't explicitly say "investigate" — pasted `/a/k6-app/...` URLs, "why did run X fail", "what happened with my test", "is my test healthy", "the latest run looks weird", "checks are failing but the run says passed", or any request to diagnose a Grafana Cloud k6 run all qualify.
npx skill4agent add grafana/skills k6-cloud-investigate-testgcx apik6-manageresultstatuschecksreferences/worked-example.mdgcx k6 load-tests update-script-vvv --log-http-payload/test_runsgcx k6 runs list --limit 0@nextLinkgcx apik6-managecreatedcheck()thresholdschecksgcxk6-managegcx --context <stack> config check # expect "✔ Connectivity: online"/a/k6-app/tests/<id>/a/k6-app/runs/<id>gcx apik6-managegcx --context <stack> api /api/plugins/k6-app/resources/cloud/cloud/v6/test_runs/<run_id>.test_idgcx --context <stack> k6 load-tests get <test_id> -o jsonk6-managek6-managek6-managegcx api@nextLinkk6-manage/cloud/v6/load_tests/<test_id>/test_runsall_runsprint(f"Total: {len(all_runs)}")
runs_sorted = sorted(all_runs, key=lambda r: r['created'], reverse=True)
for r in runs_sorted[:10]:
print(f" {r['created']:30s} id={r['id']:>8} status={r['status']:<10} result={r.get('result','?')}")last7 = [r for r in all_runs if r['created'] >= '<today_minus_7_days_iso>']len(last7) == 0| Layer | Field | Meaning |
|---|---|---|
| Run-level outcome | | Whether thresholds breached |
| Run-level status | | Whether the run finished orderly |
| In-script checks | v5 | Per-check success rate |
result: passedcheck()checksabortOnFailk6-manage/references/metrics.mdquery_aggregate_k6gcx --context <stack> api \
"/api/plugins/k6-app/resources/cloud/cloud/v5/test_runs/<run_id>/query_aggregate_k6(query='ratio by (check)',metric='checks')"checkincrease_nz by (check)increase_z by (check)k6-manage/references/metrics.md# 6a. List metrics available for the run (metrics.md §1)
gcx --context <stack> api /api/plugins/k6-app/resources/cloud/cloud/v5/test_runs/<run_id>/metrics
# 6b. List labels for a metric to know what's available to filter/group by (metrics.md §4)
gcx --context <stack> api \
"/api/plugins/k6-app/resources/cloud/cloud/v5/test_runs/<run_id>/labels?match[]=http_req_duration"
# 6c. Time-series — pick a query method that matches the metric's type (metrics.md §6)
gcx --context <stack> api \
"/api/plugins/k6-app/resources/cloud/cloud/v5/test_runs/<run_id>/query_range_k6(query='histogram_quantile(0.95) by (name,status)',metric='http_req_duration',step=10)"
# 6d. Scalar aggregate over the whole run (metrics.md §7)
gcx --context <stack> api \
"/api/plugins/k6-app/resources/cloud/cloud/v5/test_runs/<run_id>/query_aggregate_k6(query='increase',metric='http_reqs')"k6-manage/references/metrics.mdlabelslabel/{name}/valuesk6-managegcx api/api/plugins/k6-app/resources/logs/...{test_run_id="<id>"}X-K6TestRun-Idstartendrun.createdrun.ended/tmp/run_<id>_logs.jsonk6-managek6 inspectContent-Type: application/octet-streamabortOnFail==!=Test: <name> (id <test_id>)
Run: <run_id> @ <created> → <ended>, load_zone=<zone>, result=<result>
Logs (<n> streams, <m> lines):
- <stream summary>
Metrics (key indicators):
- <metric>: <method> = <value> (n=<count>)
...
Per-check breakdown:
- <check name>: <success_rate> (succ=<n>, fail=<n>)
...
Diagnosis: <one-paragraph>Question: <one-line restatement of what the user is trying to attribute>
Run timeline (relevant window):
| Run ID | Created (UTC) | Result | exec_duration | processing_duration | k6 build | error code | key check ratios |
|---|---|---|---|---|---|---|---|
| ... | ... | passed | 60s | 195s | <build> | — | 1.0/1.0/1.0 |
| ... | ... | failed | 27s | 193s | <build> | — | 0.0/n=0/n=0 |
| ... | ... | error | 51s | 3601s aborted | <build> | 8016 | 1.0/1.0/1.0 |
Differences that matter:
- <field>: <value-in-passing> vs <value-in-failing> — <interpretation>
...
Script diff (if relevant): <bundled-script diff between a representative passing and failing run, summarised>
Diagnosis: <one-paragraph attributing the change to test-side, SUT-side, or platform-side, with the supporting evidence>/tmp/k6inv/run<id>/check()resultresult | Meaning |
|---|---|
| All thresholds passed (or none defined) |
| At least one threshold failed |
| Either the script crashed before finishing (e.g. browser wouldn't launch) or k6 Cloud aborted the run platform-side. To tell which, check |
| User or system aborted the run |
check()resultcheckschecksresultchecks{check:response is 200}
✓ 'rate==1.0' rate=0.00% ← ✓ pass!?check()catchtry {
const r = await page.goto(URL);
check(r, { "response is 200": x => x.status() === 200 });
// ... rest of iteration body
check(true, { "script completed without exception": () => true });
} catch (e) {
console.error(e);
check(null, { "script completed without exception": () => false });
} finally {
await page.close();
}'checks{check:script completed without exception}': ['rate==1.0']abortOnFailWhen k6 runs in the cloud, thresholds are evaluated every 60 seconds. Thefeature may be delayed by up to 60 seconds.abortOnFail
abortOnFailresultfailed<><=>===!=raterate==1.0rate==0cloud/cloud/X-K6TestRun-Idupdatedgcx k6 runs list --limit 0@nextLinkk6-manage| Symptom | Cause | Fix |
|---|---|---|
| "Latest run was 6 months ago" but schedule says daily | You didn't paginate | Use the |
| "Last 7 days" report contains only old runs | Filtered by row count, not date | Re-filter by |
| Threshold reports ✓ pass but checks fail | Zero check observations; iteration aborted before | See "Threshold semantics" above |
| Likely a platform abort (e.g. | Check |
| Investigating a past run by reading the current load-test script | Script may have been edited since the run executed — what you're reading isn't what ran | GET the run's bundled script via the per-run endpoint ( |
| Just overwrote the user's script | Invoked | Restore from the backup taken in Step 2. To learn URLs without writing, use |
CLI | Overrides scenario block entirely | Edit |
references/worked-example.md