k6 can send performance testing metrics to Datadog. That allows visualizing and correlating performance testing metrics with other monitored metrics in Datadog.
This article outlines the instructions of the Datadog integration:
- Run the Datadog Agent
- Run the k6 test
- Visualize in Datadog
To get k6 metrics into Datadog, k6 sends metrics through the Datadog Agent, which collects, aggregates, and forwards the metrics to the Datadog platform.
Run the Datadog Agent service as a Docker container with this command:
Replace <YOUR_DATADOG_API_KEY> with your Datadog API key.
If your account is registered with Datadog EU, change the value of DD_SITE to datadoghq.eu.
For additional information, read the Datadog Docker Agent documentation.
The Datadog agent includes the DogStatsD service to collect and aggregate metrics. DogStatsD implements the StatsD protocol with some extensions. For example, DogStatsD tagging allows to collect k6 metrics with tags to distinguish between requests for different URLs, response statuses, groups, etc.
Once the Datadog Agent service is running, run the k6 test and send the metrics to the Agent with:
The environment variables for the command are:
|K6_DATADOG_ADDR||Address of the DogsStatsD service, currently only UDP is supported. The default value is localhost:8125.|
|K6_DATADOG_NAMESPACE||The namespace used as a prefix for all the metric names. The default value is k6.|
|K6_DATADOG_PUSH_INTERVAL||Configure how often data batches are sent. The default value is 1s.|
|K6_DATADOG_BUFFER_SIZE||The buffer size. The default value is 20.|
|K6_DATADOG_TAG_BLACKLIST||This is a comma-separated list of tags that should NOT be sent to Datadog. For example, "tag1, tag2". The default value is empty.|
While running the test, k6 sends metrics periodically to Datadog. By default, these metrics have k6. as the name prefix.
To learn more about all the types of k6 metrics, read the k6 Metrics guide
The first time Datadog detects the k6.http_reqs metric, the k6 integration tile is installed automatically, and the default k6 dashboard is added to your dashboard list.
Optionally, you can install the k6 integration tile following these instructions:
- Log in to Datadog.
- From the sidebar menu, choose Integrations > Integrations.
- Search for k6, then select the k6 integration.
- Click on the Configuration tab option.
- Scroll down and click on the Install integration button.