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

InfluxDB + Grafana

Want some graphs? It's simpler than you think, using InfluxDB for data storage and Grafana for visualization.

Installing InfluxDB and Grafana

First, you need to install InfluxDB.For Ubuntu users: sudo apt-get install influxdb
For MacOS users: brew install influxdbThen you need to install Grafana also.Ubuntu users: sudo apt-get install grafana
MacOS users: brew install grafanaAfter this, you should have an InfluxDB server running on localhost, listening on port 8086, and a Grafana server on http://localhost:3000

Using InfluxDB to store results

k6 has built-in support for outputting results data directly to an InfluxDB database using the --out / -o switch:

k6 run --out influxdb=http://localhost:8086/myk6db script.js
docker run -i loadimpact/k6 run --out influxdb=http://localhost:8086/myk6db - <script.js

The above command line makes k6 connect to a local influxdb instance and send results data from the test to a database named myk6db. If this database does not exist, k6 will create it automatically.Once you have k6 results in your InfluxDB database, you can use Grafana to create results visualizations.

Using Grafana to visualize results

  • Open http://localhost:3000 (or wherever your Grafana installation is located) in your browser.- Create a data source:
_click picture to enlarge_

click picture to enlarge

  • Now create a dashboard. Here is the newly created dashboard:
  • Click Graph to create a new graph panel:
  • Click the Panel title and then Edit to set up the graph panel:
  • Set the panel data source to your myk6db database and click the SELECT mean(value)... statement to edit the metric:
_Clicking the `select measurement` text lets you choose a metric to plot_

Clicking the select measurement text lets you choose a metric to plot

Using our docker-compose setup

To make all the above even simpler, we have created a docker-compose setup that will:

  • Start a Docker container with InfluxDB
  • Start a Docker container with Grafana
  • Make available a k6 container that you can use to run load tests.
    Make sure you have at least docker-compose version v1.12.0 installed.
    You just need to do the following:
git clone 'https://github.com/loadimpact/k6'
cd k6
docker-compose up -d influxdb grafana
docker-compose run --rm k6 run /scripts/es6sample.js

Now you should be able to connect to http://localhost:3000 with your browser and access the Grafana installation in the Docker container.

It is important to note that a volume is in place binding ./samples to /scripts. And to re-run the test use the command docker-compose run --rm k6 run /scripts/es6sample.js again.

Example with custom metrics

You can also visualize custom metrics from your scripts. For example, if you add a request failure Rate:

import { Rate } from "k6/metrics";

const myFailRate = new Rate('failed requests');

export default function () = {
      const res = http.get(url, params);
      myFailRate.add(res.status !== 200);

You can visualize them in Grafana like this:

Preconfigured Grafana dashboards

Here we will list premade Grafana dashboard configurations contributed by users, for use with k6. To enable a contributed Grafana dashboard is simple: you just choose to "import" a dashboard in the Grafana UI and then specify the ID number of the dashboard you want, see http://docs.grafana.org/reference/export_import/ for more details.

ID 2587, by Dave Cadwallader -

ID 2587, by Dave Cadwallader -

Updated 2 months ago

InfluxDB + Grafana

Suggested Edits are limited on API Reference Pages

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