K6 x Datadog Issues

I am trying to output my k6 results to datadog locally.

I have tried the following:

  1. Start datadog
docker run --rm -d \
    --name datadog \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -v /proc/:/host/proc/:ro \
    -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
    -e DD_SITE="datadoghq.com" \
    -p 8125:8125/udp \
  1. Run k6
K6_STATSD_ENABLE_TAGS=true k6 run --out statsd <my test>.js

I have also tried while supplying K6_STATSD_ADDR with

  • datadog:8125
  • the IP from my datadog docker process using
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' datadog

With all these, I get a similar error from k6 that the metrics are not going though.
ERRO[0005] Couldn't flush a batch error="write udp> write: connection refused" output=statsd

Any ideas would be appreciated, thanks!

Hi @kghelani

The issue seems not really related to the k6. It just tells you that couldn’t reach the address.

What I see is that you exposing the port to the host:

So in theory it should work with the standard k6’s K6_STATSD_ADDR which is localhost:8125. For sure if k6 is running on the same host machine.

If it doesn’t work with this address I’d recommend checking the documentation of the datadog/agent to see why it could refuse the connection.

Hope that helps,

I encountered the same issue as @kghelani (write: connection refused" output=statsd), and seemed to overcome it by using the container IP directly, as such:

$ docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ dd-agent


K6_STATSD_ADDR= K6_STATSD_ENABLE_TAGS=true k6 run --out statsd ./load/sample.test.js

No metrics seem to have been received by the agent, although the test seems to run successfully:

Here’s how I initialized my local DD Agent FYI:

docker run --rm -d
–name dd-agent
-v /var/run/docker.sock:/var/run/docker.sock:ro
-v /proc/:/host/proc/:ro
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
-e DD_SITE=“datadoghq.com
-e DD_API_KEY=“”
-p 8125:8125/udp

Any help appreciated! :pray: :slightly_smiling_face:

Hi @kghelani @gurgelv

Let me know if this works for you.