k6 can send performance metrics to New Relic through the New Relic StatsD integration. By integrating New Relic and k6, you can visualise and correlate test result data, alert on performance data, and share advanced load testing results and their KPI’s with your teams. Alongside all of your other telemetry data in New Relic.
The New Relic StatsD integration is a great way to quickly and easily send metrics into the Telemetry Data Platform. For any integration that includes the ability to export metrics to StatsD then integrating to New Relic is as simple as running the NR StatsD integration and including NR StatsD as an output in your test run.
Run New Relic StatsD
On the machine where k6 is installed, provision the NR StatsD integration v2.
docker run \ -d --restart unless-stopped \ --name newrelic-statsd \ -h $(hostname) \ -e NR_ACCOUNT_ID=YOUR_ACCOUNT_ID \ -e NR_API_KEY=YOUR_INSERT_API_KEY \ -p 8125:8125/udp \ newrelic/nri-statsd:2.0.0
If your account is in the EU region then add this to the above command:
-e NR_EU_REGION=true \
Check that the integration is up and running using the command:
docker ps -a
Now when you run your k6 test, include the
-out statsd flag and New Relic will start to receive k6 output metrics. The total command will look something like this:
k6 run --vus 12 --duration 30s --out statsd script.js
In New Relic you can run NRQL:
from Metric select uniques(metricName) where metricName like 'k6%' to view the metrics sent from k6. You can also just discover them in the data explorer (under the Metric table.