K6 and Datadog in Jenkins Job: Lookup Datadog no such host

I’m new to K6. We’ve been running Artillery test scripts in a Jenkins job and I was sending custom metrics to Datadog via http.

I’d like to use K6 and send metrics to Datadog via statsd.

In my Jenkins job, I first start the datadog agent container without problems like this:

docker run -d --cgroupns host --name dd-agent --network bridge -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_API_KEY=someAPIKeyHere’ -p 8125:8125/udp Google Cloud Platform

Then I try starting the k6 container like this:

docker run --network bridge --name k6-container -v /home/jenkins/agent/workspace/psr-jobs/psr-k6:/tmp -w /tmp grafana/k6 run --out statsd -e ‘DD_DOGSTATSD_NON_LOCAL_TRAFFIC=1’ -e ‘K6_STATSD_ADDR=datadog:8125’ -e ‘K6_STATSD_ENABLE_TAGS=true’ /tmp/schedule.js

The container tries to start, I see the big K6 ascii printout:

      /\      |‾‾| /‾‾/   /‾‾/   
 /\  /  \     |  |/  /   /  /    
/  \/    \    |     (   /   ‾‾\  

/ \ | |\ \ | (‾) |
/ __________ \ |__| _\ ____/ .io

but then I get this error and the job stops:

time=“2022-06-15T23:57:56Z” level=error msg=“Couldn’t make buffered client, lookup datadog on 169.254.20.10:53: no such host” output=statsd
time=“2022-06-15T23:57:56Z” level=error msg=“lookup datadog on 169.254.20.10:53: no such host”

I believe the 169.254.20.10 IP address is our Kubernetes address.

hi! I might be able to help! A few questions…

  1. Am I right in saying that you’re running k6 docker in the jx step?
  2. Do you know your datadog address? you’ve set the var as datadog:8125, just confirm what that is
  3. You’ve definitely got an agent running?
  4. If you keep the container running, can you go into container k6 and reach out to that ip?

Hi Chris, thanks for asking. Here’s my Jenkins code:

pod(label: 'psr-k6')
        .container('docker-cmd')
        .build {
            checkout scm
            container('docker-cmd') {
                stage('start k6') {
                sh 'docker version'
                sh 'docker pull grafana/k6'
                sh 'docker pull datadog/agent:latest'
                sh 'docker run -d --cgroupns host --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_API_KEY=<myAPIkey gcr.io/datadoghq/agent:7'
                sh 'docker run --name k6-container -v `pwd`:/tmp -w /tmp grafana/k6 run --out statsd -e K6_STATSD_ADDR=datadog:8125 -e K6_STATSD_ENABLE_TAGS=true /tmp/schedule.js'
            }
        }
    }

As you can see I pull the latest docker containers for both K6 and datadog. I start the DD container first, then the K6 container.

This network stuff is not my strong suit, which is why this issue has me stumped. I don’t know what my DD address is or how to find it.

I was able to confirm that the DD agent is running.

I haven’t found a way to keep the K6 container running. It shuts down as soon as it throws the error.

Walker

Thanks! I’ve got a few ideas for you, il get back to you on those. The datadog metrics output doesn’t error the test right? That should be a WARNING.

You could now either set the test duration to be long enough to give you time to exec into the pod or provide the -l command to k6 which will hold k6 to linger. Ref: Options reference

See if that helps so you can do some pings or tests, I think the issue here is DNS-related, or container talk-related.