DataDog/agent-github-action

Does not work with K6 Action

Closed this issue · 1 comments

I've been trying to use the K6 Action connected to the Datadog Agent Action, and I can't get it to work. I'm not sure which action is the source of the trouble.

These are the messages I get:

msg="Error while sending metric http_req_duration" error="write udp 127.0.0.1:44061->127.0.0.1:8125: write: connection refused" output=statsd

Here's an example workflow:

name: Load Testing

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  k6:
    runs-on: ubuntu-latest
    steps:
      - uses: datadog/agent-github-action@v1.3
        with:
          container_name: datadog-agent
          image_name: datadog/agent
          api_key: ${{ secrets.DATADOG_API_KEY }}

      - uses: actions/checkout@v2

      - uses: grafana/k6-action@v0.2.0
        with:
          filename: test.js
          flags: --out statsd --vus 10 --duration 10s --verbose
        env:
          K6_DATADOG_ADDR: datadog-agent:8125
          K6_STATSD_ENABLE_TAGS: true

And the example K6 test, in case this helps if you want to reproduce:

import http from 'k6/http';

import { Rate } from 'k6/metrics';
import { check } from 'k6';

const failRate = new Rate('failed_requests');

export const options = {
  thresholds: {
    failed_requests: ['rate<=0'],
    http_req_duration: ['p(95)<500'],
  },
  ext: {
    loadimpact: {
      projectID: 3568228,
    },
  },
};

export default function () {
  const result = http.get('https://test-api.k6.io');
  check(result, {
    'http response status code is 200': result.status === 200,
  });
  failRate.add(result.status !== 200);
}

I was able to get this to work like so:

name: Load Testing

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  web-ecs:
    runs-on: ubuntu-latest

    services:
      datadog:
        image: datadog/agent:latest
        ports:
          - 8125:8125/udp
        env:
          DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
          DD_DOGSTATSD_NON_LOCAL_TRAFFIC: true

    steps:
      - uses: actions/checkout@v2

      - uses: grafana/k6-action@v0.2.0
        with:
          filename: test.js
          flags: --out statsd --vus 10 --duration 10s --verbose
        env:
          K6_STATSD_ADDR: datadog:8125
          K6_STATSD_ENABLE_TAGS: true