Grafana k6
Active and stableRuns locally ✓No paid APIAn open-source performance-testing tool that turns JavaScript scenarios into measurable load and pass-or-fail thresholds locally and in CI.
brew install k6Ideal use for this tool
Best for a developer or small team testing an API or critical journey with gradual, repeatable load before release. Virtual users, metrics, and thresholds turn a vague sense of speed into an explicit performance condition. It is not for unauthorized targets and does not identify a bottleneck without server observability.
Details and illustrated features
An application that feels fast on a developer laptop may slow down with concurrent users or a weaker connection. Login can degrade, errors can rise under modest load, and ordinary functional tests may never expose it. Grafana k6 is an open-source performance-testing tool: describe a test in JavaScript, run it locally or in CI, measure latency, request failures, and throughput, and turn performance goals into repeatable pass-or-fail thresholds.
🧭 What is Grafana k6 and how does it work?
k6 is a load generator and performance-testing tool from Grafana Labs. A JavaScript file defines requests, virtual users (VUs), and either duration or iteration schedules. Each VU runs in an isolated context, while k6 collects built-in metrics such as HTTP request duration, failed-request rate, and iterations.
You can test APIs at the protocol layer or use the browser module with Chromium for a user journey and Web Vitals. Local execution needs neither a Grafana Cloud account nor a subscription. Cloud execution, Kubernetes distribution, and external result outputs are optional paths with their own connectivity, permissions, data handling, and cost.
This card follows the v2.4.x documentation and the stable feature release v2.4.0, published 12 November 2026. The project also published v1.8.3 as a 1.x maintenance patch on 13 November. Do not mix extension or command assumptions across release branches.

Original explanatory diagram, not a k6 UI screenshot or an executed test result.
🎯 How does it help you?
k6 fits an individual developer or small team that needs to learn whether an API or critical journey tolerates expected load before release. Instead of rapidly clicking through several windows, save a scenario in Git: begin with a tiny smoke test, establish a baseline, then increase load gradually in an authorized environment. The same scenario can be repeated after a code or infrastructure change.
The added value is not a large request count. It is a clear condition: keep a team-defined failed-request rate below its target and an appropriate latency percentile inside a service objective. Threshold failures produce a non-zero exit code for CI. k6 does not explain a bottleneck on its own, so correlate results with server metrics, logs, and traces. Never load-test a system without ownership or explicit authorization.
🌟 Key features and capabilities
1. Virtual users and gradually controlled load
A virtual user is an isolated execution context that repeats the test function. Start with one VU, then set VUs and duration or choose an executor for a more precise workload. The purpose is to model a known condition, not keep multiplying load until a system breaks.
- Where: top-level
vusandduration, orscenarios. - Use: run a short smoke test, watch failures, then increase one controlled step at a time.
- Example: ten VUs for 30 seconds repeat the defined flow, but they are not automatically equivalent to ten human users.
- Important: VUs are not requests per second; iteration duration,
sleep, network conditions, and generator capacity affect the rate.

2. Independent scenarios for different journeys
scenarios can put login, search, and checkout in one file with separate functions, schedules, loads, and tags. Scenarios run in parallel by default, and startTime can offset them. From v2.3 onward, --scenario selects one or several configured workloads without editing the file.
- Value: separate read traffic from write traffic and attribute results to named flows.
- Use: give each scenario a business name and select an executor that represents the documented rate or VU pattern.
- Constraint: do not combine
--scenariowith top-level load flags such as--vusor--duration; the tool warns about ignored conflicting settings. - Boundary: a realistic scenario needs evidence about user behaviour. Do not present a guess as observed traffic.

3. Checks observe correctness; thresholds gate delivery
check() records whether a functional condition is true, such as an HTTP status or response value, but a check alone does not fail a run. Define thresholds when a performance target or check rate must become a CI gate. Any failed threshold makes k6 exit non-zero.
- Where:
options.thresholdsand metrics such aschecks,http_req_duration, andhttp_req_failed. - Example:
p(95) < 500means 95 percent of samples for that metric must be below 500 milliseconds. - Value: distinguish response correctness from an agreed performance target.
- Important: derive the number from an SLO or baseline, not a documentation example. An average can hide a slow tail.

4. Built-in metrics, summaries, and local reports
k6 collects built-in metrics and prints an end-of-test summary. It can stream time-series points to JSON, CSV, or external outputs. A built-in Web Dashboard is enabled with K6_WEB_DASHBOARD=true, binds to localhost by default, and can export an HTML report.
- Use: start with the summary and local dashboard; add JSON or an external service when history or a shared dashboard is required.
- Value: observe latency, errors, and generated load together.
- Privacy: JSON and CSV may contain URLs, tags, check names, and errors. Review files before sharing and never put a token in a URL or tag.
- Limit: k6 shows what the generator observed; it does not reveal database or CPU causes without system observability.

5. Protocol and browser testing in one workflow
Protocol tests generate more requests with lower overhead. The k6/browser module drives Chromium and produces browser metrics and Web Vitals. The documented hybrid approach uses protocol tests for most load and a small number of browser journeys for critical flows.
- Where:
k6/httpandk6/browser, withbrowser.type = 'chromium'in scenario options. - Value: test backend capacity and a real page journey without making every VU a heavy browser.
- Requirements: local Chromium or the browser-enabled Docker image, plus more resources than a protocol test.
- Important: k6 uses its own JavaScript runtime, not Node.js; some npm packages and resolution patterns are incompatible.

6. Local, distributed, or cloud execution
k6 documents three modes: local on a machine, container, or runner; distributed on Kubernetes; and cloud through Grafana Cloud k6. A script remains broadly portable, but execution location, data handling, cost, and permissions change.
- Local: no account; requests and results stay between your machine, target, and configured outputs.
- Distributed: requires a cluster, k6 Operator, resources, networking, and Kubernetes secrets.
- Cloud: requires an account and token and may upload scripts, test data, and results according to the selected workflow.
- Cost: the local CLI is free and open source. Grafana Cloud offers a free tier and metered paid plans; inspect the current stack limits before a large run.

7. A performance gate in CI
Once a small test is stable, run it in GitHub Actions or another CI system. Store the script with code, pass the base URL and credentials through secrets, and let thresholds stop the job when a target fails. Grafana publishes the official grafana/setup-k6-action.
- Permissions: a local GitHub run generally needs repository read access and command execution. Add write access only for an integration that actually publishes a status or comment.
- Secrets: use the CI secret manager and avoid logging headers or bodies. v2.4.0 adds credential-header redaction for debug logs, but logs still require review.
- Cadence: run a smoke test on pull requests and reserve broader load for a schedule and dedicated environment.
- Limit: an undersized or shared runner can become the bottleneck and distort results.

8. Optional extensions with compatibility boundaries
k6 supports JavaScript, output, secret-source, and subcommand extensions. They can add a protocol or send metrics to a custom destination. Depending on the workflow, an extension may require a custom binary or automatic resolution.
Treat an extension as executable dependency code: verify publisher, version, and k6 compatibility. v2.4.0 changes some Go-to-JavaScript conversions, and the release notes ask extension authors to recheck compatibility. Registry presence does not make an extension part of core k6 or equally supported.

🪜 Practical example: baseline a login service
Illustrative; not run against a live system: an authorized staging environment needs a performance check for the login API.
- Agree with the owner on time, maximum load, test data, monitoring, and a stop condition.
- Install k6 v2.4.0 and verify
k6 version. - Generate
login.jswithk6 new login.js, then replace the URL with aBASE_URLvariable. - Use separate test accounts and keep passwords out of Git.
- Run one VU and one iteration; make a
checkverify response status and meaning. - Run a short smoke test while observing the application, database, and generator.
- Establish a baseline from repeated comparable runs, then choose thresholds tied to a known service objective.
- Increase one load step at a time and stop on unexpected errors or impact.
- Put the tiny test in CI and reserve larger load for a scheduled dedicated environment.
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 5,
duration: '30s',
thresholds: {
http_req_failed: ['rate < 0.01'],
http_req_duration: ['p(95) < 500'],
},
};
export default function () {
const base = __ENV.BASE_URL;
const res = http.get(`${base}/health`);
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1);
}
These figures are instructional, not recommendations for your system. Test only a target you own or have written permission to load.
⚖️ What changes compared with manual testing?
| Job | Manual approach | With k6 |
|---|---|---|
| Repeat a journey | Inconsistent clicks | Script versioned in Git |
| Generate load | A few windows or devices | Configurable VUs and executors |
| Define success | A page “feels fast” | Explicit checks and thresholds |
| Compare changes | Memory or separate screenshots | Same scenario and storable metrics |
| CI | Someone reads a report | Non-zero exit code when a threshold fails |
| Explain the cause | User observation alone | Correlate k6 with server metrics and traces |
This compares workflow structure; it is not measured time savings or a guarantee that the workload model is accurate.
⚙️ Important configuration
- scenarios/executors: choose from workload evidence, not feature complexity.
- thresholds: tie them to an SLO or baseline and recheck percentiles after upgrades that change metric definitions.
- environment variables: local
k6 runincludes system variables by default, while archive and cloud commands default to excluding them to reduce secret uploads. Do not enable--include-system-env-varswithout review. - tags: useful for endpoints and scenarios, but personal or high-cardinality values can leak data and inflate storage.
- discardResponseBodies: saves memory when bodies are unnecessary; keep bodies available for checks that depend on them.
- gracefulStop: allows iterations to finish and can lengthen CI runtime.
🚀 Installation and first run
Grafana documents Linux, macOS, and Windows packages, Docker images, and standalone binaries. On macOS:
brew install k6
k6 version
k6 new script.js
k6 run script.js
This card targets v2.4.0. Avoid an unpinned :latest in sensitive CI; pin and review release notes when upgrading. Browser tests require Chromium or a suitable image, while extensions can require a different binary.
🔗 Integrations and compatibility
k6 runs on Linux, macOS, Windows, Docker, CI, Kubernetes, and Grafana Cloud. Core capabilities include HTTP/1.1, HTTP/2, WebSocket, gRPC, browser modules, cryptography, and custom metrics, with extensions for other protocols and outputs. Its JavaScript runtime is not full Node.js, so check compatibility before bringing an npm library. In v2.4.0 the built-in InfluxDB and Prometheus remote-write outputs are deprecated for removal in v3; the release notes recommend moving to the OpenTelemetry output.
💰 Cost, local operation, and privacy
The repository uses AGPL-3.0. Local CLI execution needs no subscription or paid API; you pay for your machine, network, target, and any external storage. Grafana Cloud k6 is optional, with a free tier and paid usage based on virtual-user hours. The effective limits appear in the current stack.
In a local run, k6 reads the script and files you explicitly open, sends requests to configured targets, and writes selected outputs. The local dashboard binds to 127.0.0.1:5665 by default. External outputs, remote modules, and cloud execution transmit data to another service. Result files can contain URLs, tags, and error text, so treat them as test data. Prefer synthetic accounts over customer data.
⚠️ Limitations and when not to use it alone
- Performance testing does not establish functional correctness or security.
- Unauthorized load can disrupt a service, affect customers, or violate provider terms.
- A weak generator or unstable network can bottleneck before the target.
- One run is not a reliable baseline; control conditions and repeat measurements.
- Browser VUs are heavier and should not generate most load.
- Checks do not fail a run without a threshold.
- The JavaScript runtime is not full Node.js.
- Production tests need stop controls, monitoring, and coordination; a production-like staging environment is usually a safer starting point.
- k6 does not identify the bottleneck by itself or replace server observability.
🔐 Security and permissions
Run k6 as a normal user with read access to scripts and test data and write access only to result folders. It needs network access to targets and any selected module, output, or cloud service. Browser tests launch Chromium; containers need explicit volumes and output write permissions.
Store tokens in a secret manager, not in scripts, --http-debug, or tag names. Do not use real customer data without necessity and approval. Constrain BASE_URL in CI so untrusted pull requests cannot redirect load to an arbitrary host. Review remote modules and extensions because they execute as part of the test. Set load and duration limits, define a stop condition, and coordinate large tests with operations.

Original diagram of safe operating controls, not evidence that a particular target is authorized.
📚 Sources and verification date
Verified 21 November 2026 using the original repository, v2.4.0 release, installation guide, running tests, scenarios, thresholds, results, web dashboard, and JavaScript compatibility.
GitHub showed about 32.3k stars and 1.7k forks at verification time. These are changing popularity signals, not quality ratings. We did not install k6 or run an actual load test; every example is marked illustrative.