Creating A Basic Load Test Infrastructure Via Using K6/Grafana/InfluxDB

Berkay Kırmızıoğlu
2 min readJul 27, 2022

--

It’s a lot of fun when you can successfully review performance test charts and metrics.

In this article, I tried to explain how you can create a Performance test Playground very quickly with K6/Grafana/InfluxDB.

If your Pre-requisites are OK, I hope 5 Minutes should be enough for up & running basic performance test infra.

A Kind Note: This is of course an initial setup. I tried to explain it simply and without giving too much detail so that testers can gain experience easily with this playground.

Pre-requisite:

  • Docker should be installed and running
  • Homebrew should be installed on your Mac

Example API: https://test-api.k6.io/public/crocodiles/

Let’s start with running these commands;

brew install k6

git clone https://github.com/grafana/k6.git

Then go to local git repository that you clone into your local machine and run

docker compose up

Then you will see;

Now your Grafana and InfluxDb should be up and running.

Grafana -> http://localhost:3000/

InfluxDb -> http://localhost:8086/

Now it’s time to create our performance test script;

Go to your terminal

touch performancetest.js

vi -f performancetest.js

And let’s write this script;

Now it’s time to run our test script. We will point to InfluxDb so that it can write our test results.

k6 run — out influxdb=http://localhost:8086/k6 performancetest.js

When test is finished, you should be able to see these basic outputs;

And the MAGIC and fun part!!!

  1. Let’s open our local Grafana dashboard list.

http://localhost:3000/dashboards

2. You should see ready k6-performance-test which is installed with k6 repository. Let’s open it!

With this default dashboard you can analyze Virtual Users and Http Request Durations. For more; you can view and import these dashboards.

I will continue my articles about K6 soon. Next, I will talk about how you can load test on k8 with thousands of users.

Happy Performance Testing!

--

--

Berkay Kırmızıoğlu
Berkay Kırmızıoğlu

Written by Berkay Kırmızıoğlu

Open Source Enthusiast, Software Engineer & SDET

No responses yet