---
title: "Stream results to Grafana Cloud k6 | Grafana Labs"
description: "Add Grafana Cloud k6 credentials to CI and stream automated test results for persistent storage and team visibility."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Stream results to Grafana Cloud k6

Without cloud output, automated results often live only in pipeline logs unless you configure retention or an external results backend. Streaming to Grafana Cloud k6 stores each run, visualizes metrics, and gives your team a shared history across deploys.

For CI, prefer a [Grafana Stack API token](/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication/#get-a-grafana-stack-api-token) so runs aren’t tied to a personal account. You’ll also need a Grafana Cloud k6 project ID.

Get your Grafana Cloud k6 credentials from Performance settings.

1. In the main menu, go to **Testing &amp; synthetics** &gt; **Performance** &gt; **Settings**.
2. If you’re an administrator, under **Access**, click **Stack token**, then create or copy the token to a temporary location for later use.
   
   A Stack token is better for shared CI pipelines because runs aren’t tied to one person’s account. Don’t put the token in your script.
3. If you’re not an administrator, under **Access**, click **Personal token**, then copy the token to a temporary location for later use.
   
   Use this for learning, then switch to a Stack token before you rely on this setup in a shared pipeline. Don’t put the token in your script.
4. Under **Access**, click **Stack ID**, then copy the ID to a temporary location for later use.
5. In the main menu, go to **Testing &amp; synthetics** &gt; **Performance** &gt; **Projects**.
6. Open a project, then under the project name copy **Project id**.
   
   You’ll store it as a CI secret in the next part of this milestone.

You now have the Grafana Cloud credentials to store as CI secrets.

Next, wire those credentials into your pipeline so automated runs stream to Grafana Cloud k6.

Add secrets in your CI platform:

- GitHub Actions: **Settings** &gt; **Secrets and variables** &gt; **Actions** &gt; **New repository secret**. Create `K6_CLOUD_TOKEN`, `K6_CLOUD_PROJECT_ID`, and `K6_CLOUD_STACK_ID`.
- GitLab CI: **Settings** &gt; **CI/CD** &gt; **Variables**. Add the same names and mark `K6_CLOUD_TOKEN` as **Masked**.

Update your GitHub Actions job to pass the cloud environment variables. With `grafana/run-k6-action`, providing `K6_CLOUD_TOKEN` and `K6_CLOUD_PROJECT_ID` streams results by default (local execution with cloud output). Include `K6_CLOUD_STACK_ID` so the job works with k6 v2:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
- name: Setup k6
  uses: grafana/setup-k6-action@v1

- name: Run k6 test
  uses: grafana/run-k6-action@v1
  env:
    K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
    K6_CLOUD_PROJECT_ID: ${{ secrets.K6_CLOUD_PROJECT_ID }}
    K6_CLOUD_STACK_ID: ${{ secrets.K6_CLOUD_STACK_ID }}
  with:
    path: tests/performance/test.js
    flags: --env BASE_URL=https://staging.example.com
```

Replace `https://staging.example.com` with your environment URL. If authentication fails, re-check the three secrets. Refer to [Authenticate on the CLI](/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication/).

For GitLab CI or any Docker-based runner, authenticate with the token and stream with `k6 cloud run --local-execution`. Include `K6_CLOUD_STACK_ID` because `grafana/k6:latest` may be k6 v2:

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
performance-test:
  image:
    name: grafana/k6:latest
    entrypoint: ['']
  stage: test
  variables:
    K6_CLOUD_TOKEN: $K6_CLOUD_TOKEN
    K6_CLOUD_PROJECT_ID: $K6_CLOUD_PROJECT_ID
    K6_CLOUD_STACK_ID: $K6_CLOUD_STACK_ID
  script:
    - k6 cloud run --local-execution -e BASE_URL=https://staging.example.com tests/performance/test.js
```

Replace the sample `BASE_URL` with your environment URL.

Push the updated configuration and open the new pipeline run. In the job logs, k6 prints a cloud URL for the test run.

Open that URL, or in Grafana Cloud go to **Testing &amp; synthetics** &gt; **Performance**, and confirm the run appears with latency, error rate, and throughput metrics.

If the job fails with an auth error, re-check `K6_CLOUD_TOKEN`, `K6_CLOUD_PROJECT_ID`, and `K6_CLOUD_STACK_ID`.

> **Note:** Streaming results consumes Grafana Cloud k6 usage (VUH or test runs) according to your plan. Refer to [Grafana Cloud k6](/docs/k6/latest/results-output/real-time/cloud/) for streaming vs cloud execution modes.

You’ve moved k6 from a local laptop tool to a team dependency in CI/CD, with shared results in Grafana Cloud.

In the next milestone, you wrap up and choose where to go next for operationalizing gates and expanding coverage.
