No results for

Powered byAlgolia

Grafana Cloud

Using Grafana Cloud Prometheus and the k6 extension for Prometheus remote write, you can send your k6 metrics into Grafana Cloud to better visualize your testing results, enabling you to correlate k6 metrics with other metrics of your observability stack.

While this article focuses on Grafana Cloud, any remote-write capable Prometheus installation is compatible with this approach.

attention

For k6 Cloud tests, follow the k6 Cloud instructions.

Set up Grafana Cloud Prometheus

If you do not have a Grafana Cloud account, you can sign up here. The free plan includes 10,000 Prometheus series.

Now, you need the URL, username and password of your Grafana Cloud Prometheus instance to configure the integration.

Log in to Grafana.com and visit the Cloud Portal. Click on the Details button of your Prometheus service.

Grafana Cloud Portal

Copy the URL of the Remote Write Endpoint and the Username / Instance ID.

Grafana Cloud Prometheus Configuration

On the Password / API Key section, create and copy an API key of MetricsPublisher role that will be used as password.

Create API Key

Build the k6 version

To output k6 metrics to Prometheus, you have to run a k6 version built with the extension for Prometheus remote write.

To build a k6 binary with the extension, first, ensure you have installed Go and Git; the following steps are:

# Install xk6
go install go.k6.io/xk6/cmd/xk6@latest
# Build the k6 binary
xk6 build --with github.com/grafana/xk6-output-prometheus-remote
... [INFO] Build environment ready
... [INFO] Building k6
... [INFO] Build complete: ./k6

xk6 will create the k6 binary in the local folder.

To learn more about how to build custom k6 versions, check out xk6

Run the test

Now, pass the Username, API key, and Remote Write Endpoint of the Grafana Cloud Prometheus Configuration to the k6 binary built with the extension as follows:

K6_PROMETHEUS_USER=Your_Username \
K6_PROMETHEUS_PASSWORD=Your_API_KEY \
K6_PROMETHEUS_REMOTE_URL=Your_REMOTE_WRITE_ENDPOINT \
./k6 run script.js -o output-prometheus-remote

Explore k6 metrics

In Grafana Cloud, click on the Explore icon on the menu bar, and choose the Prometheus data source from the dropdown in the top left. In the query field, query k6 metrics to explore your testing results.

Explore k6 metrics in Grafana Cloud

Read more