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:
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:
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:
If the remote write endpoint requires authentication, the following command can be used:
Options
Here is the full list of options that can be configured and passed to the extension:
Name | Value |
---|---|
K6_PROMETHEUS_REMOTE_URL | Address of the Prometheus Remote Write endpoint. The default value is http://localhost:9090/api/v1/write. |
K6_PROMETHEUS_USER | User for the basic HTTP authentication at the Prometheus Remote Write endpoint. Optional. |
K6_PROMETHEUS_PASSWORD | Password for the basic HTTP authentication at the Prometheus Remote Write endpoint. Optional. |
K6_PROMETHEUS_FLUSH_PERIOD | Interval of the metrics' aggregation and upload to the endpoint. The default value is 1s. |
K6_PROMETHEUS_MAPPING | Type 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_VERIFY | Boolean option whether to skip TLS verification on the endpoint. The default value is true. |
K6_CA_CERT_FILE | Location of the CA certificate file required by the endpoint. Optional. |
K6_KEEP_TAGS | Boolean option whether to send k6 tags as labels for each metric. The default value is true. |
K6_KEEP_NAME_TAG | Boolean 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. |
K6_KEEP_URL_TAG | Boolean option whether to send url k6 tag to labels for each metric. Note: see HTTP Requests URL Grouping for explanation on values of url tag why you might want to use name instead of url to reduce cardinality. The default value is true. |