Here’s a clean, copy-paste-ready beginner tutorial to install Grafana k6 OSS on Windows, write a “Hello World” load test, run it, and understand the results.
You have a few options. I’ll show the two easiest:
-
Open Windows Terminal / PowerShell as Administrator.
-
Run:
winget install grafana.k6
-
After install, verify:
k6 version
You should see something like:
k6 v0.xx.x
If you’re already using Chocolatey:
-
Open PowerShell (Admin).
-
Install:
choco install k6
-
Verify:
k6 version
-
Go to:
https://github.com/grafana/k6/releases(in your browser). -
Download the latest Windows x64 .zip.
-
Extract it to a folder, e.g.:
C:\tools\k6\ -
Add that folder to your PATH:
-
Press
Win→ search Environment Variables → “Edit the system environment variables”. -
Click Environment Variables…
-
Under User variables or System variables, select
Path→ Edit → New → add:C:\tools\k6\ -
Click OK several times.
-
-
Open a new PowerShell and run:
k6 version
Let’s keep things clean.
-
Choose a workspace folder, e.g.:
mkdir C:\k6-demo cd C:\k6-demo
-
You’ll put all your k6 scripts here.
We’ll create a very simple script that:
- Sends 1 HTTP GET request to a test URL.
- Checks that the response status is 200.
- Prints basic stats at the end.
- In
C:\k6-demo, create a file namedhello-world.js.
If you like using Notepad:
notepad .\hello-world.jsPaste this code inside:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 1, // number of virtual users
duration: '10s', // total test duration
};
export default function () {
// 1) Make a simple GET request
const res = http.get('https://test.k6.io');
// 2) Validate response
check(res, {
'status is 200': (r) => r.status === 200,
});
// 3) Small pause between iterations
sleep(1);
}Save and close the file.
From inside the folder:
cd C:\k6-demo
k6 run .\hello-world.jsYou will see something like:
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / /
/ \ | |\ \/ /
/ __________ \ |__| \____/
execution: local
script: hello-world.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10s max duration (incl. graceful stop):
* default: 1 looping VUs for 10s (gracefulStop: 30s)
running (10.0s), 0/1 VUs, 10 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 10s
✓ status is 200
checks...................: 100.00% ✓ 10 ✗ 0
http_req_duration........: avg=150ms min=120ms max=200ms ...
http_reqs................: 10 (1.0/s)
vus......................: 1
Important fields to understand:
-
checks – shows how many checks passed/failed:
✓ 10 ✗ 0→ all 10 requests returned status 200.
-
http_req_duration – time it took to complete each HTTP request.
avg,min,max, percentiles.
-
http_reqs – total number of HTTP requests (10 here).
-
vus – how many virtual users were active (1 here).
Since status is 200 is the only check, if the website failed or returned a different code, you’d see failed checks.
Now, let’s add a threshold so the test “fails” if latency is too high.
Create another file: hello-with-threshold.js
notepad .\hello-with-threshold.jsPaste:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 2,
duration: '15s',
thresholds: {
// 95% of all requests must finish below 500ms
http_req_duration: ['p(95) < 500'],
// At least 99% of checks must pass
checks: ['rate > 0.99'],
},
};
export default function () {
const res = http.get('https://test.k6.io');
check(res, {
'status is 200': (r) => r.status === 200,
});
sleep(1);
}Run it:
k6 run .\hello-with-threshold.jsAt the end, you’ll see something like:
checks................: 100.00% ✓ 30 ✗ 0
http_req_duration.....: p(95)=180ms ...
thresholds:
* http_req_duration p(95)<500 ✓ passed
* checks rate>0.99 ✓ passed
If you intentionally use a slow or broken URL, you might see thresholds marked as failed with ✗.
If you just want to quickly confirm your script works (like a smoke test):
Create hello-smoke.js:
notepad .\hello-smoke.jsPaste:
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
vus: 1,
iterations: 1, // run only once
};
export default function () {
const res = http.get('https://test.k6.io');
console.log(`Response status: ${res.status}`);
sleep(1);
}Run:
k6 run .\hello-smoke.jsYou’ll see a log line:
INFO[0000] Response status: 200
This is a super basic “Hello World” just to embed k6 in a CI step or script.
If you continue learning, you might organize like:
C:\k6-demo
├─ hello-world.js
├─ hello-with-threshold.js
├─ hello-smoke.js
├─ scenarios/
│ ├─ basic-load.js
│ ├─ spike-test.js
├─ data/
│ └─ users.csv
Once this works, good next things to explore:
-
Increase load Change:
vus: 10, duration: '30s',
-
Add multiple URLs Use
group()blocks and multiplehttp.getcalls. -
Export results to JSON (for later analysis):
k6 run --out json=results.json .\hello-world.js
-
Integrate with Grafana later (Prometheus or k6 Cloud), once you’re comfortable.
If you tell me:
- Your Windows version (e.g. Windows 10/11), and
- Whether you prefer PowerShell or Command Prompt
I can give you an even more tailored, copy-paste script that:
- Installs k6
- Creates all 3 hello-world scripts
- Runs them one by one automatically.