capillary-tech
Published in

capillary-tech

Integrating NewRelic with K6 in kubernetes cluster

k6 is the leading load testing engine developed for the engineering teams. With load test execution in place, it is equally important and critical to have reliable result visualisation. K6 supports many integrations for visualising the data and metrics. Reference

However, here specifically we will focus on, how teams can integrate NewRelic with k6 if whole setup is deployed in kubernetes cluster and visualise the results by preparing k6 dashboards in New Relic.

k6 can send the telemetry data to NewRelic via NewRelic StatsD Integration. Capillary engineering team uses NewRelic extensively for monitoring applications, having performance tests numbers as a NewRelic dashboards is something like “icing on the cake”.

To have this integration to work, we would need to deploy the NewRelic StatsD in k8s cluster that will send the telemetry data to NewRelic server.

K6-NewRelic Integration

Let’s get into it!

First create the config map that will set the configurations for nri-statsd via a “toml” file as following yaml.

nri-statsd is an open source project for “StatsD integration for New Relic”.

NR_ConfigMap.yaml

“address” and “address-metrics” will contain the event endpoint and metrics endpoint of newRelic.The “api-key” and the “newRelic-accountid” is the actual api key and account id of NewRelic server.

Next is to create a “deployment” for NewRelic StatsD, that will typically use the above config map and uses the latest image “newrelic/nri-statsd:latest” in the container. Following is the yaml.

NR_StatsD_Deployment.yaml

The environment variables “NR_ACCOUNT_ID”, “NR_API_KEY” has to be set with valid NewRelic api-key and account_id. This can also be added to configMap to use in deployment. The “replicas” and “port” can be customised based on requirement.

Further step would be to create a clusterIP service that will open the connection to StatsD deployment/pods. Following is the yaml.

NR_StatsD_svc.yaml

Exposed service port can be any valid port but protocol has to be UDP, as NewRelic StatsD uses UDP.

To access the configuration files visit the git project here.

Apply the above objects to K8s cluster in sequence, or just create a script for it.

Perfect!! NewRelic StatsD is running via UDP with endpoint “newrelic-statsd-svc:80”. Now to use the StatsD to send the data from k6 to NewRelic server, we would need to use “statsd” as an output and “K6_STATSD_ADDR” as “newrelic-statsd-svc:80” while executing k6 script, as follows —

k6 run --out statsd --env K6_STATSD_ADDR=newrelic-statsd-svc:80

Once this setup is done, k6 will be sending the performance metrics to the New Relic StatsD integration which in turn is sending these metrics to the New Relic Telemetry Data Platform. These will be prefixed with “k6”. So we can search the metrics inside “Data Explorer” as follows

k6 metrics

And eventually you can add all the required k6 metrics to the NewRelic Dashboard. For example as below

k6 Dashboard

Hope this helps and provide ease in setting up NewRelic for k6 in K8s cluster, Further there is an interesting setup that Capillary uses to run the load tests in distributed way which is very much needed for any engineering teams to test the system at scale. The “What” and “How” of the setup and architecture of such solution in K8s cluster will come up in next part of this.

Stay Tuned :)

--

--

--

This publication showcases candid stories highlighting how intelligent technology enables a highly scalable omnichannel CRM, eCommerce, and loyalty management software at Capillary Technologies

Recommended from Medium

Host your Alexa Skills for Free

Getting Started With Helm 3 Using React and Codefresh

Why Reactive? Thread per Request vs. Reactive Programming Model (Eventloop)

Mutable and Immutable objects in Python

How to make a custom pagination from an array in laravel.

9 skills that could be essential for growing your tech business in 2021 — Talent Works…

How to Tell Your IT Team What You Actually Need for Your Next Product

How to create a Kotlin back-end server (ktor + exposed + flyway + jwt)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nayan Gaur

Nayan Gaur

I write and share strategies on Leadership | technology | Product Quality.

More from Medium

Event Driven Autoscaling

Graceful Shutdown in Kubernetes — Theory, Implementation, and Testing

An introduction to Service Mesh

On-premise to cloud migration mock drills using Istio