As I gathered around but still not find a solid solution so asking for the great help from the community.
My context would be following:
- The k6 load tests will be executed on Gitlab CI. This part is done. I could make the tests are up the running.
- Now I want to send the results to new relic. There is a guide here Forums. It needs to run a docker command, only my local it works like a charm.
docker run \
-d --restart unless-stopped \
--name newrelic-statsd \
-h $(hostname) \
-e NR_ACCOUNT_ID=YOUR_ACCOUNT_ID \
-e NR_API_KEY=YOUR_INSERT_API_KEY \
-p 8125:8125/udp \
- However, the issue is with Gitlab CI, I could not manage to start that
localhost:8125 on gitlab, hence the results could not be send to new relic.
I would appreciate if anyone experienced the same and found a solution for it.
Hi there, welcome to the forum
I’m not deeply familiar with Gitlab CI, but couldn’t you start the New Relic container as part of the
services key in the
.gitlab-ci.yml? See their documentation for examples.
You should be able to specify all arguments and environment variables you need there, and then target the container in k6 with the StatsD environment variables. Though I’m unsure how Gitlab CI names the services or if you’ll have to reference it by IP, some testing is needed there.
hey, so I am not familiar with GitLab but if you can run the New Relic integration remotely and doesn’t need to be on your localhost. Have you tried that? I think it should work
This should in theory work by just pointing the output to a remote host running the New Relic StatsD integration.
Based at least on this guide and in the script section you would just have to append the script to be like
K6_STATSD_ADDR=<AWS Public IP or hostname>:8125 k6 run ./loadtests/performance-test.js as that will override the localhost which is set by default.
I have just tried this by spinning up the integration on an AWS t2.micro to act as a relay between my k6 client on my laptop to output the metrics to New Relic StatsD running on the AWS instance, relaying those metrics into my New Relic account.
Here’s what I did:
- Spin up an EC2 t2.micro, configure it. I used Amazon Linux 2.
- Set a security policy that you can SSH into it to install the integration (port 22), allow incoming/outgoing traffic on port 8125 (StatsD)
- Install Docker
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo chkconfig docker on
- Run the New Relic StatsD Integration
docker ps -a check docker container is there
- When running my k6 test from my local client set the env var like:
K6_STATSD_ADDR=220.127.116.11:8125 k6 run --out statsd test.js
- In New Relic you should be seeing the hostname of my AWS instance like so
So you just have to switch it up in step 6, set the env var to point at your remote host with the integration running.
There may be a smarter way of doing this by having GitLab run the docker container (?? no idea sorry)
Let me know if that solves it for you
@imiric @gspncr Thanks all for your inputs, appreciated that much. With some helps from devops team, I managed to make it work on Gitlab CI. So probably I post it here and anyone who may stuck like me could find a way out.
All right, so in my k6 project, I created a Dockerfile, something like this:
ADD . / k6-test/
RUN npm install
command: npm run k6-test
Last but not least is the .gitlab-ci.yaml
- apk add docker-compose --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
- docker-compose up --abort-on-container-exit
Then the pipeline is up and running Hope this helps.
Hi, team. Hope everyone is doing well. I am trying to integrate NewRelic-K6 with Gitlab and managed to install the docker container but when executing the script I am getting “K6 not found” error. Kindly help me with this. Attached the piepline and .gitlab-ci.yml file images for reference
gitlab yml File image:
Hi all, I am able to run k6 commands now but facing new issues with the connections. Kindly find the attached screenshot.
I am getting “write udp 127.0.0.1:56403->127.0.0.1:8125: write: connection refused” output=statsd" error.
Any help would be greatly appreciated.
Any updates? I am stuck at same point