A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Guides


k6 Custom Metrics API

The metrics module provides functionality to create custom metrics of various types. All metrics (both the built-in ones and the custom ones) have a type. There are four different metrics types, and they are: Counter, Gauge, Rate and Trend.

All values added to a custom metric can optionally be tagged which can be very useful when analysing the results after a test run.

Metric type

A metric that cumulatively sums added values.

A metric that stores the min, max and last values added to it.

A metric that tracks the percentage of added values that are non-zero.

A metric that allows for calculating statistics on the added values (min, max, average and percentiles).

import { Counter, Gauge, Rate, Trend} from "k6/metrics";
import { check } from "k6";

var myCounter = new Counter("my_counter");
var myGauge = new Gauge("my_gauge");
var myRate = new Rate("my_rate");
var myTrend = new Trend("my_trend");

export default function() {
  myCounter.add(2, { tag1: "myValue", tag2: "myValue2" });
  myGauge.add(456, { tag1: "myValue", tag2: "myValue2" });
  myRate.add(false, { tag1: "value", tag2: "value2" });
  myTrend.add(2, { tag1: "value", tag2: "value2" });


k6 Custom Metrics API

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.