This project sets up a monitoring and visualization system using Prometheus and Grafana with Docker Compose, enabling users to observe performance tests executed via k6.
Prometheus, a time-series database, is configured to accept remote write requests from k6, allowing it to store and scrape performance metrics. Grafana, a powerful visualization tool, is then used to create dashboards for real-time analysis of the collected data.
This setup provides an efficient and scalable way to monitor system performance and visualize test results, making it ideal for load testing and performance tracking.
I'm a curious Software Quality Assurance Engineer who loves to experiment with different tools and technologies that helps me doing my job in a better way ...
-
Framework - for k6 to do the performance tests.
-
Automated Monitoring Setup: Uses Docker Compose to automate the deployment of Prometheus and Grafana.
-
Remote Write Support: Prometheus is configured to accept remote write requests from k6, enabling seamless integration of performance test data.
-
Performance Test Metrics: Collects and stores performance test metrics from k6 using Prometheus.
-
Real-Time Visualization: Grafana dashboards allow real-time visualization and analysis of performance metrics.
-
Custom Dashboards: Easily create and customize Grafana dashboards to monitor key metrics and test results.
-
Persistent Data Storage: Grafana’s data is stored in named volumes to ensure persistence across container restarts.
k6 Performance Test Project
This repository contains a complete setup for running performance tests using k6, with Prometheus as the data collection backend and Grafana for visualizing the test results.
By utilizing Docker Compose, this project automates the deployment of Prometheus and Grafana, allowing you to efficiently monitor and analyze the performance of your system under test.
Prerequisites:
Docker: Install Docker on your machine.
Windows: https://www.docker.com/products/docker-desktop/
Docker Compose: Ensure Docker Compose is installed (it comes with Docker Desktop).
Download k6: https://k6.io/open-source/
To deploy this project
Setup Instructions
- Clone the Repository
git clone https://github.com/easabbir/k6-performance-test.gitcd k6-performance-test- Run the docker-compose.yml file
The docker-compose.yml file defines the services for Prometheus and Grafana. It also mounts the Prometheus configuration file (prometheus.yml).
Run Docker Compose Run the following command to start Prometheus and Grafana:
docker-compose up -dPrometheus will be available at http://localhost:9090
Grafana will be available at http://localhost:3000
(default credentials: admin/admin)
- Configure Grafana
Go to Grafana (http://localhost:3000).
Log in with the default credentials (admin/admin), and skip setting password for now.
Add Prometheus as a data source:
Navigate to Configuration > Data Sources > Add Data Source.
Select Prometheus and set the URL to http://prometheus:9090.
Click Save & Test.
- Run k6 Performance Tests You can now run k6 tests and push the metrics to Prometheus.
Example
k6 run -o experimental-prometheus-rw .\tests\basic_test.js- Create Grafana Dashboards Go to Grafana's home page and click on Create > Dashboard. Add a Graph panel. Select the Prometheus data source and use queries like k6_http_req_duration_seconds_count to visualize k6 test results.
Alternatively Add dashboard eg 19665_rev3.json as added in the project as a json file
Conclusion
This project provides a fully automated setup to monitor and analyze performance tests using k6, Prometheus, and Grafana. With this setup, you can easily run load tests and visualize real-time data in customizable Grafana dashboards.
This documentation should be a great starting point for anyone looking to get up and running with your project. Let me know if you'd like to make any adjustments!
To run tests, run the following command
Example
k6 run -o experimental-prometheus-rw .\tests\basic_test.js