K6 x Datadog Issues

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

I have tried the following:

  1. Start datadog
DOCKER_CONTENT_TRUST=1 \
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" \
    -e DD_API_KEY=<YOUR_DATADOG_API_KEY> \
    -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=1 \
    -p 8125:8125/udp \
    datadog/agent:latest
  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 192.168.1.246:49185->172.17.0.2:8125: 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,
Cheers!

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
172.17.0.2

Then:

K6_STATSD_ADDR=172.17.0.2:8125 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_CONTENT_TRUST=1
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=“”
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
-e NON_LOCAL_TRAFFIC=true
-p 8125:8125/udp
datadog/agent:latest

Any help appreciated! :pray: :slightly_smiling_face:

Hi @kghelani @gurgelv

Let me know if this works for you.