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 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.
In the main menu, go to Testing & synthetics > Performance > Settings.
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.
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.
Under Access, click Stack ID, then copy the ID to a temporary location for later use.
In the main menu, go to Testing & synthetics > Performance > Projects.
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 > Secrets and variables > Actions > New repository secret. Create
K6_CLOUD_TOKEN,K6_CLOUD_PROJECT_ID, andK6_CLOUD_STACK_ID. - GitLab CI: Settings > CI/CD > Variables. Add the same names and mark
K6_CLOUD_TOKENas 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:
- 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.comReplace https://staging.example.com with your environment URL. If authentication fails, re-check the three secrets. Refer to Authenticate on the CLI.
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:
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.jsReplace 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 & synthetics > 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 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.
Please tell us what didn't work: