No results for

Powered byAlgolia

Prometheus

k6 supports sending test result metrics to a Prometheus Remote Write endpoint via the xk6-output-prometheus-remote extension. One option with this support is storing the metrics in Prometheus; others can be found here.

Instructions

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

Then run the test with the new binary as follows:

./k6 run -o output-prometheus-remote script.js

All metrics sent by the extension get the prefix k6_ attached to their names. In case of Prometheus, k6 metrics can be seen in its UI:

k6 metrics as seen in the Prometheus UI

If the remote write endpoint requires authentication, the following command can be used:

K6_PROMETHEUS_INSECURE_SKIP_TLS_VERIFY=false \
K6_PROMETHEUS_USER=foo \
K6_PROMETHEUS_PASSWORD=bar \
./k6 run script.js -o output-prometheus-remote

Options

The full list of available options that can be configured and passed to the extension:

NameValue
K6_PROMETHEUS_REMOTE_URLAddress of the Prometheus Remote Write endpoint. The default value is http://localhost:9090/api/v1/write.
K6_PROMETHEUS_HEADERSAdditional headers to include in the HTTP requests. Optional.
K6_PROMETHEUS_USERUser for the basic HTTP authentication at the Prometheus Remote Write endpoint. Optional.
K6_PROMETHEUS_PASSWORDPassword for the basic HTTP authentication at the Prometheus Remote Write endpoint. Optional.
K6_PROMETHEUS_PUSH_INTERVALInterval of the metrics' aggregation and upload to the endpoint. The default value is 5s.
K6_PROMETHEUS_INSECURE_SKIP_TLS_VERIFYBoolean option whether to skip TLS verification on the endpoint. The default value is true.

Grafana Dashboards

The extension repository includes a docker-compose setup with two pre-built dashboards to:

  • list test runs
  • visualize the results of a test run

Prometheus list test runs

Prometheus k6 results

Read more