K6 performance script integrates with K6 Cloud

Panduka Wijekoon
4 min readJul 10, 2024

--

In our previous article (https://pandukawijekoon.medium.com/api-performance-testing-using-k6-c662b91dd4a6), I discussed how to write a K6 performance script for testing API performance. In this article, I discuss how to integrate the K6 performance test script with the K6 Cloud.

K6 Cloud now supports integration with Grafana. Grafana Cloud k6, a unified platform introduced by Grafana Labs, integrates the K6 performance testing experience directly into Grafana Cloud. This allows users to visualize and analyse test results in real-time using Grafana dashboards.

Let’s begin,

Step 1 -
Create an account on Grafana Cloud

URL — https://grafana.com/auth/sign-up/create-user?pg=login

Step 2 -
Login to the Grafana Cloud

Step 3 -
Launch your Grafana Cloud by clicking the ‘Launch’ button

Step 4 -
Navigate to the K6 section by clicking the ‘Start Testing’ button

Step 5 -
Create a new project by clicking the ‘Create new project’ button under the ‘Projects’ section

You have to provide a unique name for the project and other information mentioned below as per your requirements.

  1. Max VUh per month — The maximum number of concurrent users multiplied by the number of hours per month.
  2. Max VUs per test — The maximum number of concurrent users per test.
  3. Max duration per test — The maximum test execution duration per test.

I provided the values mentioned below in the image as per my requirement.

Step 6 -
Click on the ‘Create new test’ button to connect your test script with the K6 Cloud project

Since we have already installed K6 locally, we can skip the ‘Install k6’ step and continue from the ‘Authenticate’ step.

Execute the above command in your project’s terminal. By doing so, you can log in to the K6 Cloud through your project.

Implement the ‘Create a script’ step to connect your K6 test script with the K6 cloud project.

Instead of copying the above mentioned JSON object ‘cloud’, paste the below mentioned object in your test script’s options section.

Replace the ‘projectID’ value with the created K6 cloud project id. You can rename the ‘name’ value as your wish.

    ext: {
loadimpact: {
// Project: K6_CRUD
projectID: 3704126,
// Test runs with the same name groups test runs together.
name: 'Test (09/07/2024-23:08:22)'
}
}

Here is an example,

Then, you can run the test by executing the ‘Run a test’ step.

While the test script is running, you can visualize and analyse test results in real-time on the K6 Cloud dashboard.

--

--

Panduka Wijekoon
Panduka Wijekoon

Written by Panduka Wijekoon

Senior QA Engineer | Cypress | CircleCI | Jenkins | Selenium | Appium

No responses yet