statsd / statsd

Daemon for easy but powerful stats aggregation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New Relic integration GitHub Actions

claudiolcastroTW opened this issue · comments

I’m working on some performance tests with K6 and at the moment I’m trying to send the reports to New relic via StatsD integration.
I was following this Doc New Relic StatsD integration to do the integration, but as we are running the tests on GitHub actions pipeline, I started to face some issues to make the things work.
Context:
running docker container on Gh action step:

- name: Run New Relic Docker
       run: |
         docker run \
           -d --restart unless-stopped \
           --name newrelic-statsd \
           -h $(hostname) \
           -e NR_ACCOUNT_ID=${{ secrets.NEW_RELIC_ACCOUNT_ID }} \
           -e NR_API_KEY=${{ secrets.NEW_RELIC_LICENSE_KEY }} \
           -p 8125:8125/udp \
           newrelic/nri-statsd:latest

then running k6 scripts

- name: My test
     uses: grafana/k6-action@v0.2.0
     with:
       filename: script.js
       cloud: false
       flags: --out cloud --out statsd --env K6_STATSD_ENABLE_TAGS=true

Error
level=error msg="Couldn't flush a batch" error="write udp 127.0.0.1:39623->127.0.0.1:8125: write: connection refused" output=statsd
It seems that the script runner is unable to communicate with new relic docker container. (probably Im doing something wrong (?) )
Does anyone have any idea about how to solve that?
thanks

Hi @claudiolcastroTW, I'm afraid I don't have any idea how the newrelic/nri-statsd docker image is put together, I assume it's maintained by the New Relic team since it's not something we own. Since we don't control that image it's hard to comment on what the networking setup might be that's causing you a problem here.

My only suggestion is that I'm wondering if the newrelic/nri-statsd container should be setup as a service rather than a run step? Assuming these are sequential steps in a github action pipeline, your container will be setup in that first step and then terminated and then the next step which runs your k6 script will run.

Typically to start a container for the duration of a job you'll need something like this.

jobs:
  deps:
    name: Build and test
    runs-on: ubuntu-latest

    services:
      db:
        image: postgres:11
        ports: ['5432:5432']
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
      - name: Checkout
        uses: actions/checkout@v2.4.0
        with:
          fetch-depth: 0
     [... continue with additional steps]

The above is a cut down rip from another project of mine, you can see here I'm setting up the postgres:11 container to run for the duration of the job, in future steps I have various scripts which end up calling out to that postgres instance.

I'm not sure if this helps, I could be way off the mark but we're nothing to do with New Relic so you'd really have to consult them if it's their guide and their container image causing issues and the above doesn't help.

Hey @BlueHatbRit thanks a lot for your answer! That was exactly the problem. I was not running the docker container as a service. Jus did and everything worked. Thanks! ;)

Just to keep the record:

services:
      newrelic-statsd:
        image: newrelic/nri-statsd:latest
        ports:
          - 8125:8125/udp
        env:
          NR_ACCOUNT_ID: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
          NR_API_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}

This worked fine;

I'll close the issue

Glad to hear that worked for you!