Skip to content

bhuwantm/k6-load-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load Testing and Visualization using k6, Prometheus and Grafana

Tools used:

  • Prometheus
  • Prometheus/node_exporter
  • Grafana
  • InfluxDB
  • k6

 

Setup and Running the test

Create .env file by copying .env-example. Change the variable value as you wish.

cp .env-example .env

Run the docker compose file. Add -d at the end if you want to run it in detached mode.

docker-compose up -d

Run the demo test script using following command:

docker-compose run k6 run /tests/script.js

Note: For detail grafana setup see Grafana Setup setction below

 

Notes:

  • All this is setup in our local machine only
  • The system metrcis collected by node_exporter is from our localhost, as it installed locally
  • To collect the system metrics from another server we need to install node_exporter to that server and configure it in prometheus.yml
  • The API endpoint used in this demo is "http://test.k6.io" (provided by k6). So, the API metrics collected is for this endpoint.

 

Prometheus

Open source systems monitoring and alerting toolkit. It collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.

Docker Network URL: http://prometheus:9090

Local URL: http://localhost:9090

 

Prometheus/node_exporter

Prometheus exporter for hardware and OS metrics. Collects metrics and exposes them to an endpoint, which Prometheus can consume.

 

Grafana

It is an open source data visualization tool developed by Grafana Labs (which also developed K6). It allows us to query, visualize, alert on and understand metrics from multiple sources into a single centralized location.

Docker Network URL: http://grafana:9091

Local URL: http://localhost:9091

 

InfluxDB v1.x.x

The Time Series Database for storage and retrival of time series data like application metrics, system metrics, IoT sensor data etc.

Docker Network URL: http://influxdb:8086

Local URL: http://localhost:8086

 

k6

Open source load testing tool for testing the performance of your backend infrastructure.

  • Written in Go for faster performance
  • Test Script is written in javascript

 

Grafana Setup

Go to Grfana URL and login using the username and password provided in .env file. http://localhost:9091

Add Prometheus data source using following settings

Prometheus Settings

Add influxdb data source using following settings

Use usename and password as defined in .env file.

Note: If there is no data in influxdb then it might show error which is fine for now.

InfluxDB Settings

Import Dashboard Developed by community or build your own Explore dashboard from Graphana Dashboards and import as required using Dashboard ID.

Import Dashboard

Suggested dashboard:

About

k6, Prometheus and Grafana setup using docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published