Send test results to Grafana Cloud
In this milestone, you send your k6 test results to Grafana Cloud. When streaming results to the cloud, your local machine runs the test and uploads the results to Grafana Cloud, where you can visualize and analyze them in real-time through the web interface.
Streaming results to Grafana Cloud enables you to access detailed dashboards, historical test data, and advanced analysis tools that aren’t available in the terminal output. You can also share test results with your team and track performance trends over time.
To send test results to Grafana Cloud, complete the following steps:
Sign in to your Grafana Cloud account at Grafana Cloud if you haven’t already.
Log in to Grafana Cloud k6 using your API token:
k6 cloud login --token <YOUR_API_TOKEN>You can find your API token in Grafana Cloud under Testing & synthetics > Performance > Settings — under access, click personal token or stack token. For details, see Grafana Cloud k6 account settings.
Alternatively, you can skip the login step and pass the token directly in the run command.
Run your test with the
--local-executionflag to stream results to Grafana Cloud:k6 cloud run --local-execution script.jsIf you didn’t log in previously, you can pass the token as an environment variable:
K6_CLOUD_TOKEN=<YOUR_API_TOKEN> k6 cloud run --local-execution script.jsNote
The
--local-executionflag runs the test on your local machine and streams results to the cloud. This differs fromk6 cloud run(without the flag), which uploads your script to run on cloud infrastructure.Observe the test execution in your terminal. k6 displays real-time progress and provides a URL to view results in Grafana Cloud:
execution: local output: cloud (https://acmecorp.grafana.net/a/k6-app/runs/123456) script: script.jsCopy the URL displayed in the terminal output. This URL takes you to the test results dashboard in Grafana Cloud.
While the test is running, the test run state will be marked as
Running. When the test completes, it will be marked asFinished. You can view results in real-time as data streams to the cloud.If you encounter connection issues or the test fails to stream results, verify that your API token is correct and that you have network connectivity. For more help, refer to the Grafana Cloud k6 documentation.
In the next milestone, you’ll analyze the test results in Grafana Cloud dashboards to understand performance metrics and identify potential issues.
