Use this skill when writing or debugging Grafana k6 load testing code.
This skill enables access to the latest official Grafana k6 documentation for writing and debugging load testing scripts. k6 is a modern load testing tool built for performance testing APIs, microservices, and websites.
Use this skill when:
Access the latest k6 documentation using the WebFetch tool:
Primary documentation URLs:
Common API reference URLs:
Usage pattern:
Use WebFetch with the appropriate documentation URL and a focused prompt like:
- "Show me the API reference for http.post method"
- "Explain how to use checks in k6"
- "Show examples of custom metrics"
Basic HTTP GET test:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
};
export default function () {
const res = http.get('https://test.k6.io');
check(res, {
'status is 200': (r) => r.status === 200,
});
sleep(1);
}
HTTP POST with JSON:
import http from 'k6/http';
import { check } from 'k6';
export default function () {
const url = 'https://httpbin.test.k6.io/post';
const payload = JSON.stringify({
name: 'test',
});
const params = {
headers: {
'Content-Type': 'application/json',
},
};
const res = http.post(url, payload, params);
check(res, {
'status is 200': (r) => r.status === 200,
});
}
When searching for specific k6 functionality:
Start broad: Use WebSearch to find relevant documentation pages
Then go specific: Use WebFetch on the most relevant documentation URL
For API methods: Navigate to the JavaScript API section
For how-to guides: Check the "Using k6" section
Test lifecycle:
init context: Load-time code (imports, options)setup(): Runs once before testsdefault function(): VU code, runs repeatedlyteardown(): Runs once after testsLoad options:
vus: Number of virtual usersduration: Test durationiterations: Total iterations across all VUsstages: Ramping patternthresholds: Pass/fail criteriaHTTP methods:
http.get(), http.post(), http.put(), http.delete()http.batch() for parallel requestsChecks vs Thresholds:
check(): Validates conditions, doesn't stop testthresholds: Define pass/fail criteria, can abort test| Topic | URL Pattern |
|---|---|
| Main docs | https://grafana.com/docs/k6/latest/ |
| JavaScript API | https://grafana.com/docs/k6/latest/javascript-api/{module}/ |
| HTTP module | https://grafana.com/docs/k6/latest/javascript-api/k6-http/ |
| Examples | https://grafana.com/docs/k6/latest/examples/ |
| Test lifecycle | https://grafana.com/docs/k6/latest/using-k6/test-lifecycle/ |
| Thresholds | https://grafana.com/docs/k6/latest/using-k6/thresholds/ |
| Options | https://grafana.com/docs/k6/latest/using-k6/k6-options/ |
| Metrics | https://grafana.com/docs/k6/latest/using-k6/metrics/ |
| Checks | https://grafana.com/docs/k6/latest/javascript-api/k6/check/ |
/latest//latest/ with the specific version number