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 PRW 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 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_PROMETHEUS_REMOTE_URL=http://localhost:9090/api/v1/write \
./k6 run script.js -o output-prometheus-remote

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_REMOTE_URL=https://localhost:9090/api/v1/write \
K6_PROMETHEUS_INSECURE_SKIP_TLS_VERIFY=false K6_CA_CERT_FILE=tls.crt \
K6_PROMETHEUS_USER=foo K6_PROMETHEUS_PASSWORD=bar \
./k6 run script.js -o output-prometheus-remote

Options

Here is the full list of 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_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_FLUSH_PERIODInterval of the metrics' aggregation and upload to the endpoint. The default value is 1s.
K6_PROMETHEUS_MAPPINGType of mapping that indicates how k6 metric types should be mapped to remote storage metric types. The default value is prometheus. Other supported values: raw.
K6_PROMETHEUS_INSECURE_SKIP_TLS_VERIFYBoolean option whether to skip TLS verification on the endpoint. The default value is true.
K6_CA_CERT_FILELocation of the CA certificate file required by the endpoint. Optional.
K6_KEEP_TAGSBoolean option whether to send k6 tags as labels for each metric. The default value is true.
K6_KEEP_NAME_TAGBoolean option whether to add name k6 tag to labels for each metric. Note: see HTTP Requests Tags for explanation on values of name tag when HTTP requests are made. The default value is false.

See also