Menu
Open source

StatsD

Warning

The built-in StatsD output has been deprecated on k6 v0.47.0. You can continue to use this feature by using the xk6-output-statsd extension, and this guide has been updated to include instructions for how to use it.

For more information on the reason behind this change, you can follow this issue in the k6 repository.

k6 can push test metrics to a StatsD service by using the xk6-output-statsd extension.

Build the k6 version

To build a k6 binary with the extension, first, make sure you have Go and Git installed on your machine.

Then, open your terminal and run the following commands:

bash
# Install xk6
go install go.k6.io/xk6/cmd/xk6@latest

# Build the k6 binary
xk6 build --with github.com/grafana/xk6-output-statsd

... [INFO] Build environment ready
... [INFO] Building k6
... [INFO] Build complete: ./k6

xk6 will create the new k6 binary in the local folder.

Note

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

Run the k6 test

Using the k6 binary you built in the previous step, you can use the --out output-statsd option when running your tests to use this extension:

bash
$ ./k6 run --out output-statsd script.js

The following options can be configured:

NameValue
K6_STATSD_ADDRAddress of the statsd service, currently only UDP is supported. The default value is localhost:8125.
K6_STATSD_NAMESPACEThe namespace used as a prefix for all the metric names. The default value is k6.
K6_STATSD_PUSH_INTERVALConfigure how often data batches are sent. The default value is 1s.
K6_STATSD_BUFFER_SIZEThe buffer size. The default value is 20.
K6_STATSD_ENABLE_TAGSIf true enables sending tags. false by default as old versions of statsd, prior to v0.9.0 did not support tags.
K6_STATSD_TAG_BLOCKLISTThis is a comma-separated list of tags that should NOT be sent to statsd. For example, “tag1,tag2”. The default value is vu,iter,url.