MCPcopy
hub / github.com/grafana/k6

github.com/grafana/k6 @v2.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.1.0 ↗
9,716 symbols 46,336 edges 977 files 3,645 documented · 38%
README

  <img src="https://github.com/grafana/k6/raw/v2.1.0/assets/logo.svg" alt="Grafana k6" width="210" height="210" />

















  <img src="https://github.com/grafana/k6/raw/v2.1.0/assets/grafana-labs.svg" alt="Grafana Labs" width="210" />

Like unit testing, for performance

Modern load testing for developers and testers in the DevOps era.

Github release Build status Go Report Card Codecov branch

@k6_io on Twitter

<a href="https://github.com/grafana/k6/releases">Download</a> ·
<a href="https://grafana.com/docs/k6/latest/">Documentation</a> ·
<a href="https://community.grafana.com/c/grafana-k6/70">Community Forum</a> ·
<a href="https://github.com/orgs/grafana/projects/443/views/1">Public Roadmap</a>

---

k6 is a modern load-testing tool, built on our years of experience in the performance and testing industries. It's built to be powerful, extensible, and full-featured. The key design goal is to provide the best developer experience.

Its core features are:

  • Configurable load generation. Even lower-end machines can simulate lots of traffic.
  • Tests as code. Reuse scripts, modularize logic, version control, and integrate tests with your CI.
  • A full-featured API. The scripting API is packed with features that help you simulate real application traffic.
  • An embedded JavaScript engine. The performance of Go, the scripting familiarity of JavaScript.
  • Multiple Protocol support. HTTP, WebSockets, gRPC, Browser, and more.
  • Large extension ecosystem. You can extend k6 to support your needs. And many people have already shared their extensions with the community! Explore the available extensions.
  • Flexible metrics storage and visualization. Summary statistics or granular metrics, exported to the service of your choice.
  • Native integration with Grafana cloud. SaaS solution for test execution, metrics correlation, data analysis, and more.

This is what load testing looks like in the 21st century.

Example script

import http from "k6/http";
import { check, sleep } from "k6";

// Test configuration
export const options = {
  thresholds: {
    // Assert that 99% of requests finish within 3000ms.
    http_req_duration: ["p(99) < 3000"],
  },
  // Ramp the number of virtual users up and down
  stages: [
    { duration: "30s", target: 15 },
    { duration: "1m", target: 15 },
    { duration: "20s", target: 0 },
  ],
};

// Simulated user behavior
export default function () {
  let res = http.get("https://quickpizza.grafana.com");
  // Validate response status
  check(res, { "status was 200": (r) => r.status == 200 });
  sleep(1);
}

You can run scripts like this on the CLI, or in your CI, or across a Kubernetes cluster.

[!NOTE] Don't want to write code ?

We got you! Meet k6 Studio, a desktop application made to help you generate k6 scripts without having to touch code!

Documentation

The docs cover all aspects of using k6. Some highlights include:

  • Get Started. Install, run a test, inspect results.
  • HTTP requests. Have your virtual users use HTTP methods. Or, check the other Protocols.
  • Thresholds. Set goals for your test, and codify your SLOs.
  • Options. Configure your load, duration, TLS certificates, and much, much more.
  • Scenarios. Choose how to model your workload: open models, closed models, constant RPS, fixed iterations, and more.
  • Results output. Study, filter, and export your test results.
  • JavaScript API. Reference and examples of all k6 modules.
  • Extensions. Extend k6 for new protocols and use cases.

These links barely scratch the surface! If you're looking for conceptual information, you can read about Test types, Test strategies, or one of the many informative Blog posts.

Roadmap

Our team is dedicated to continuously improving and providing the best user experience possible. The public roadmap covers user-oriented features, UX improvements and JavaScript support that our team will focus on. Remember that timeframes and priorities may shift, but we believe it's important to share our vision.

We hope it provides a clear overview of our plans for future development. We welcome feedback, corrections, and suggestions via GitHub to make it more comprehensive, accessible, and valuable for the community.

It's worth mentioning that we consider upvotes (thumbs-up) to be one of the essential metrics for determining community needs. If you want to show us the importance of a feature, please give it a thumbs-up.

Contribute

If you want to contribute or help with the development of k6, start by reading CONTRIBUTING.md. Before you start coding, it might be a good idea to first discuss your plans and implementation details with the k6 maintainers—especially when it comes to big changes and features. You can do this in the GitHub issue for the problem you're solving (create one if it doesn't exist).

Note: To disclose security issues, refer to SECURITY.md.

Support

To get help, report bugs, suggest features, and discuss k6 with others, refer to SUPPORT.md.

License

k6 is distributed under the AGPL-3.0 license.

Extension points exported contracts — how you extend this code

Module (Interface)
Module is the interface js modules should implement in order to get access to the VU [23 implementers]
js/modules/modules.go
RecordReader (Interface)
RecordReader is the interface that wraps the action of reading records from a resource. The data module RecordReader in [11 …
internal/js/modules/k6/data/data.go
Sink (Interface)
Sink is a sample sink which will accumulate data in specific way [5 implementers]
metrics/sink.go
WithStopWithTestError (Interface)
WithStopWithTestError allows output to receive the error value that the test finished with. It could be nil, if the test [5 …
output/types.go
HasAbortReason (Interface)
HasAbortReason is a wrapper around an error with an attached abort reason. [5 implementers]
errext/abort_reason.go
Source (Interface)
Source is the interface a secret source needs to implement [4 implementers]
secretsource/extension.go
SampleContainer (Interface)
SampleContainer is a simple abstraction that allows sample producers to attach extra information to samples they return [4 …
metrics/sample.go
Builder (Interface)
(no doc) [11 implementers]
internal/lib/summary/machinereadable/cog/builder.go

Core symbols most depended-on inside this repo

Equal
called by 2448
lib/execution_segment.go
Run
called by 1843
lib/executors.go
Errorf
called by 1430
internal/js/modules/k6/browser/log/logger.go
Error
called by 656
internal/js/modules/k6/experimental/streams/readable_stream_controller.go
Debugf
called by 514
internal/js/modules/k6/browser/log/logger.go
Get
called by 437
secretsource/extension.go
Runtime
called by 391
js/modules/modules.go
NullDurationFrom
called by 333
lib/types/types.go

Shape

Function 4,385
Method 4,019
Struct 998
Interface 140
TypeAlias 99
FuncType 41
Class 34

Languages

Go85%
TypeScript15%
Python1%

Modules by API surface

internal/js/modules/k6/browser/tests/static/react-dom.development.js979 symbols
internal/js/modules/k6/browser/browser/mapping_test.go323 symbols
js/modules/k6/html/elements_gen.go187 symbols
internal/js/modules/k6/browser/common/frame.go149 symbols
internal/js/modules/k6/browser/common/page.go148 symbols
internal/js/modules/k6/browser/common/js/injected_script.js148 symbols
js/modules/k6/html/elements.go144 symbols
internal/output/cloud/expv2/pbcloud/metric.pb.go141 symbols
internal/js/modules/k6/browser/tests/static/react.development.js119 symbols
internal/js/modules/k6/browser/common/frame_options.go97 symbols
internal/js/modules/k6/browser/common/element_handle.go95 symbols
internal/cmd/tests/cmd_run_test.go88 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

buf.build/gen/go/gogo/protobuf/protocolbuffers/gov1.36.11-20240617172 · 1×
buf.build/gen/go/prometheus/prometheus/protocolbuffers/gov1.36.11-20260331160 · 1×
github.com/Azure/go-ntlmsspv0.1.1 · 1×
github.com/Masterminds/semver/v3v3.5.0 · 1×
github.com/Soontao/goHttpDigestClientv0.0.0-2017032008261 · 1×
github.com/andybalholm/brotliv1.2.1 · 1×
github.com/andybalholm/cascadiav1.3.3 · 1×
github.com/beorn7/perksv1.0.1 · 1×
github.com/bufbuild/protocompilev0.14.1 · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×

For agents

$ claude mcp add k6 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact