RousselTMLEARNING

Observability

Grafana Cloud k6

Grafana Cloud k6: load testing with k6, scenarios and thresholds, running from the Cloud or locally, load zones, analysing results correlated with metrics and traces, k6 Studio, CI and best practices.

1. What is Grafana Cloud k6 for? #

Load tests written as code, run at scale.

The principle #

Available in: ✕ OSS ✕ Enterprise ✓ Cloud k6: open source

k6 is Grafana Labs' open source load testing tool: tests are written in JavaScript, versioned with the code and run from the command line. Grafana Cloud k6 adds large-scale execution from load zones around the world, test history and comparison, and result analysis next to the tested application's metrics, logs and traces.

Grafana Cloud k6

Test types #

TestQuestion asked
Smokedo the script and application work with 1 to 5 users?
Average loaddo we handle usual traffic within latency goals?
Stresswhat happens beyond, and where do we break?
Spikecan we survive a sudden spike (campaign, sales)?
Soakdo memory leaks or drifts appear over several hours?

2. Writing a test #

Scenarios, checks and thresholds.

A complete script #

// load-api.js: progressive ramp-up with pass/fail thresholds
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  stages: [
    { duration: '2m', target: 50 },    // ramp up to 50 virtual users
    { duration: '5m', target: 50 },    // plateau
    { duration: '1m', target: 0 },     // ramp down
  ],
  thresholds: {
    http_req_failed: ['rate<0.01'],                      // less than 1% errors
    http_req_duration: ['p(95)<400', 'p(99)<1000'],      // p95 < 400 ms, p99 < 1 s
  },
  cloud: { name: 'Catalog API - average load', distribution: { paris: { loadZone: 'amazon:fr:paris', percent: 100 } } },
};

export default function () {
  const res = http.get('https://api.example.com/products?page=1');
  check(res, { 'status 200': (r) => r.status === 200 });
  sleep(1);
}

Checks or thresholds? #

  • A check validates a response (status, content) and counts successes, without stopping the test.
  • A threshold defines the pass criterion of the whole test: if breached, k6 returns an error code, which fails the CI pipeline.
Best practice : Derive thresholds from your SLOs (p95 under 400 ms, less than 1% errors): the load test then directly checks the service commitment.

k6 Studio #

Grafana k6 Studio is a desktop app that records a journey in the browser and generates the matching k6 script, with correlation of dynamic values (tokens, IDs). Handy to get started, to review before use.

3. Running #

Locally, from the Cloud, in CI.

Commands #

k6 run load-api.js                       # local run, to fine-tune
k6 cloud login --token $K6_CLOUD_TOKEN     # Grafana Cloud k6 token
k6 cloud run load-api.js                 # run from Grafana Cloud load zones
k6 cloud run --local-execution load-api.js   # load generated locally, results sent to the Cloud
  • From the Cloud: load generators in several zones (Paris, Frankfurt, Virginia…), to test a public service at scale.
  • Local with results in the Cloud: for an internal service, load comes from your network and analysis stays centralized.
  • Private load zones: generators in your own Kubernetes cluster, driven from Grafana Cloud k6.

In CI #

# .gitlab-ci.yml (excerpt): performance regression test before release
perf:
  image: grafana/k6:latest
  script:
    - k6 cloud login --token $K6_CLOUD_TOKEN
    - k6 cloud run tests/load-api.js      # fails if a threshold is breached

4. Analysing results #

Understanding where and why it breaks.

In Grafana Cloud k6 #

  • Curves of virtual users, throughput, latency (p95, p99) and errors during the test, per request and per zone.
  • Comparison with previous runs of the same test: a regression shows between versions.
  • Automatic result analysis (saturated generators, rising errors, breached thresholds).
  • Correlation with the application's metrics, logs and traces in the same stack: you see the database saturate when latency degrades.

Best practices #

  • Test a representative environment (same size, same data) and warn teams: a load test looks like an attack.
  • Always start with a smoke test, then ramp up gradually.
  • Watch the generators: if they saturate (CPU), they are the limit, not the application.
  • Billing is counted in virtual user hours: keep long and massive tests for important milestones.

Commands to know #

Commands to know
  • k6 run script.js : run locally
  • k6 cloud login --token … : log in to Grafana Cloud k6
  • k6 cloud run script.js : run from load zones
  • k6 cloud run --local-execution script.js : local load, results in the Cloud
  • thresholds: { http_req_duration: ['p(95)<400'] } : test pass criterion

Your turn #

  1. Write a smoke test on a test API with an error threshold.
  2. Turn it into an average load test (stages) and run it in Grafana Cloud k6.
  3. Add it to your CI pipeline and make it fail by lowering the latency threshold.

Sources #

Checked in November 2026: Grafana Cloud offerings change fast, check Grafana's “What's new” page before relying on a detail.

Related articles

Time-based vs event-based SLO: understanding, computing and choosing (with the Qonto example)

Differences between time-based SLOs (time slices, uptime) and event-based SLOs (good events over total): defi…

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Grafana administration and security: organizations, teams, RBAC, service accounts and authentication

Running Grafana in a company: organizations, teams, folders, roles and RBAC, data source permissions, service…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!