Getting Started with k6 tests in Load Impact

Streaming your k6 results to Load Impact Insights gives you the benefits of:

Load Impact API token


First, you need to get your Load Impact API token from the Profile settings page in the Insider program panel (
https://app.loadimpact.com/account/insiders) in the "Manage API Token" field. Copy it and set environment variable K6CLOUD_TOKEN as specified below.



Install k6

You can install k6 with a simple command using docker: 
docker pull loadimpact/k6
Don't have docker? Check out the alternative ways to install k6.



Run first test

Let's create a simple load test called script.js.
import http from "k6/http";
import { sleep } from "k6";

// Test run configuration
export let options = {
  // ramp up from 0 to 10 VUs during 60 seconds
  stages: [
    { duration: "60s", target: 10 }
  ],

  // set loadimpact k6 test name
  ext: {
    loadimpact: {
      name: 'My-First-Test'
    }
  }
}

// Test run scenario
export default function() {
  http.get('http://test.loadimpact.com/pi.php?decimals=5');
  sleep(1);
};
To run the test streaming the results to the Load Impact Insights - run the following command using docker:

docker run -i -e K6CLOUD_TOKEN=<insert_your_api_token> \ loadimpact/k6 run -o cloud - <script.js

You can read about more options about to run your k6 tests.

Note: If your running Docker on Windows the command is slightly different, see Running k6 in Docker on Windows

When executed the command line output will contain a URL link to your results in Load Impact.



Copy the URL and open it in your browser to follow along your k6 results in real time.




See next: k6 Insights overview

Feedback and Knowledge Base