Skip to content

ClarkuCSCI/docker-k6-grafana-influxdb

Repository files navigation

docker-k6-grafana-influxdb

Demonstrates how to run load tests with containerized instances of k6, Grafana and InfluxDB.

Getting Started

First, ensure that you have Docker installed and running on your computer.

Next, start the containers in the csci220-django project. We will be load testing http://127.0.0.1:8080/minifacebook/, so be sure you can load that page before continuing. Also, ensure that the page shows users' statuses: if you don't see any statuses, you should run add_fb_bots.py, as described in the "Query Processing and Optimization" lab.

Next, clone this project. Then, start the InfluxDB and Grafana containers by running:

docker compose up -d influxdb grafana

These containers will record and display metrics on load testing, respectively.

Open http://localhost:3000/d/k6/k6-load-testing-results to view the graph dashboard. Since you haven't yet run any tests, the dashboard won't yet contain any data.

Finally, run the load testing script:

docker compose run --rm k6 run /scripts/minifacebook.js

Load testing should run without warnings. For example, if you see "Request Failed" warnings, k6 may be unable to communicate with the web app. In this case, check the configuration of the external django network.

As the script runs, results will appear in the graph dashboard.

Article

This is the accompanying source code for this article. Please read for a detailed breakdown of the code and how K6, Grafana and InfluxDB work together using Docker Compose.

Dashboards

The dashboard in /dashboards is adapted from this k6 dashboard.

There are only two small modifications:

  • The data source is configured to use the docker created InfluxDB data source
  • The time period is set to now-5m, which I feel is a better view for most tests

Releases

No releases published

Packages

No packages published