Running k6 in a container with datadog visualization

Hello,

I’ve gotten my local machine to run k6 and visualize data in datadog using the datadog docker container by following the docs here:

Is there a way to output to datadog if I were to run k6 from a docker container?

I tried running this locally:
docker run --link datadog:datadog -v /src:/src -i loadimpact/k6 run --out datadog /src/script.js

but end up with something like:
time="2020-11-17T20:49:36Z" level=warning msg="Couldn't send 4 out of 58 metrics. Enable debug logging to see individual errors" type=datadog time="2020-11-17T20:49:36Z" level=error msg="Couldn't commit a batch" error="write udp 127.0.0.1:45472->127.0.0.1:8125: write: connection refused" type=datadog

I haven’t tried to reproduce this, but I think because you used --link datadog:datadog, you should also set the K6_DATADOG_ADDR=datadog:8125 environment variable in the k6 container, to configure its DataDog output to point to the other container. So, something like this:

docker run -e "K6_DATADOG_ADDR=datadog:8125" --link datadog:datadog -v /src:/src -i loadimpact/k6 run --out datadog /src/script.js

That was it - thanks!