⚠️ For k6 Cloud tests, follow the k6 Cloud instructions.
k6 can send telemetry data to New Relic through the New Relic StatsD integration. Within New Relic you can find your k6 performance data alongside your real users data and server side performance. This data can be visualized in dashboards and shared with others, used to compare load impact with system performance, and alert on metrics too.
This guide covers running the New Relic integration:
- Run the New Relic StatsD integration
- Run the k6 test
- Visualize k6 telemetry in New Relic
To get k6 metrics into New Relic, k6 sends metrics to the New Relic StatsD integration which will take care of collecting, aggregate, format and send the telemetry to the New Relic Telemetry Data Platform. You can run this with or without a New Relic agent.
Run the New Relic integration as a Docker container with this command:
If your account is hosted in the New Relic EU region, then also add this to the above command: -e NR_EU_REGION=true \
The required environment variables used in the above command are:
|NR_ACCOUNT_ID||The Account ID used in New Relic You can find your account ID here.|
|NR_API_KEY||The Insert API Key for your New Relic account to send k6 telemetry to the account ID specified above. You can generate an Insert API key here.|
Optional environment variables you can use:
|NR_EU_REGION||Setting this to true tells the integration your account is housed in the New Relic EU region.|
|TAGS||Setting tags in key:value format separated by a space lets you further understand your data in New Relic. For example identifying different test runs or machines running the tests. In the docker command add: -e TAGS="k6Test:myExampleTest someKey:someValue" \.|
|NR_LOG_METRICS||Setting this to true activates verbose logging for the integration.|
The New Relic StatsD integration installed above can run standalone. Installing a New Relic agent is optional.
Everything provided in the command above is enough to send k6 performance metrics to New Relic. You can optionally however add further configuration, further define metrics and their formats (you can however do this on the New Relic side configuration), add custom tags, and create alerts. This is covered in the optional table below.
Once the integration is running, run the k6 test and send the metrics to the integration with:
Please look at the StatsD output page for configuration options.
As your k6 test is running, k6 is sending performance metrics to the New Relic StatsD integration which in turn is sending these metrics to the New Relic Telemetry Data Platform. These will be prefixed with k6. so you can identify them.
You can visualize the metrics sent from this integration in the data explorer in the top right of New Relic (query your data).
Here are some example NRQL queries you can easily copy and paste into widgets in a New Relic dashboard, you can however stick with the chart builder. Find all your k6 Metrics under the metrics tab, prefixed with k6.
Number of Virtual Users
90th Percentile Request Duration
Max, Median, and Average Request Duration
Rate of Requests
Data Sent and Data Received
Histogram bucketing Requests
Change in the number of Requests
Scrolling List of all k6 Performance Metrics