A complete containerized solution for real-time load testing visualization using Locust, Prometheus, and Grafana. This project provides a fully automated monitoring stack with pre-configured dashboards, data sources, and secure networking for comprehensive load testing analysis.
Data Flow:
Locust → Metrics Exporter → Prometheus → Grafana Dashboard
All services run in an isolated Docker network with automatic service discovery and configuration provisioning.
Clone the repository
git clone <repository-url>
cd locustgrafanastream
Start all services
docker-compose up -d
Access the applications
Clone and navigate to the project
git clone <repository-url>
cd locustgrafanastream
Start the complete monitoring stack
docker-compose up -d
Access the applications
Service | URL | Credentials |
---|---|---|
🕷️ Locust Web UI | http://localhost:8089 | N/A |
📊 Grafana Dashboard | http://localhost:3000 | admin/admin |
🔍 Prometheus | http://localhost:9090 | N/A |
📈 Raw Metrics | http://localhost:9646/metrics | N/A |
Start load testing
jsonplaceholder.typicode.com
locustgrafanastream/
├── Dashboard/
│ ├── dashboard.json # Pre-configured Grafana dashboard
│ └── provisioning/
│ ├── dashboards.yml # Dashboard auto-provisioning config
│ └── datasources.yml # Prometheus datasource config
├── images/
│ ├── locustgraphanastream.drawio.png # Architecture diagram
│ └── *.png # Documentation screenshots
├── load_tests/
│ ├── loadtest.py # Locust test scenarios
│ └── __pycache__/ # Python bytecode cache
├── prometheus/
│ └── prometheus.yml # Prometheus scraping configuration
├── docker-compose.yml # Complete stack definition
├── .gitignore # Git ignore rules
└── README.md # This documentation
locust:
image: locustio/locust
ports:
- "8089:8089"
volumes:
- ./load_tests/:/mnt/locust
command: -f /mnt/locust/loadtest.py
networks:
- monitoring
restart: unless-stopped
read_only: true
Test Scenarios:
GET /posts
- Fetch all postsGET /posts/1/comments
- Fetch comments for a specific postGET /photos
- Fetch all photosGET /todos
- Fetch all todosGET /users
- Fetch all userslocust-metrics-exporter:
image: containersol/locust_exporter
ports:
- "9646:9646"
environment:
- LOCUST_EXPORTER_URI=http://locust:8089
depends_on:
- locust
networks:
- monitoring
restart: unless-stopped
read_only: true
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
ports:
- "9090:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
networks:
- monitoring
restart: unless-stopped
read_only: true
Scraping Configuration:
locust-metrics-exporter:9646
prometheus_scrapper
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
- ./Dashboard/dashboard.json:/etc/grafana/provisioning/dashboards/dashboard.json:ro
- ./Dashboard/provisioning/dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml:ro
- ./Dashboard/provisioning/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro
environment:
- GF_SECURITY_ADMIN=${GF_SECURITY_ADMIN:-admin}
- GF_SECURITY_PASSWORD=${GF_SECURITY_PASSWORD:-admin}
depends_on:
- prometheus
networks:
- monitoring
restart: unless-stopped
read_only: true
The pre-configured Grafana dashboard includes:
# Custom Grafana credentials
export GF_SECURITY_ADMIN=myusername
export GF_SECURITY_PASSWORD=mypassword
docker-compose up -d
Edit load_tests/loadtest.py
:
from locust import HttpUser, task, between
class CustomAPI(HttpUser):
wait_time = between(1, 3)
host = "https://your-api.com"
@task
def custom_endpoint(self):
self.client.get("/your-endpoint")
Dashboard/
Dashboard/provisioning/dashboards.yml
to include new dashboard# Verify all services are running
docker-compose ps
# Check service logs
docker-compose logs locust
docker-compose logs prometheus
docker-compose logs grafana
# View metrics endpoint
curl http://localhost:9646/metrics
Visit http://localhost:9090/targets to verify:
locust-metrics-exporter:9646
is UPThe Prometheus data source is auto-configured with:
http://prometheus:9090
Docker Desktop not running
# Verify Docker is running
docker --version
docker-compose --version
Port conflicts
# Check for port conflicts (Windows)
netstat -an | findstr "3000 8089 9090 9646"
Services failing to start
# Check individual service logs
docker-compose logs [service-name]
# Restart specific service
docker-compose restart [service-name]
# Stop and remove all containers, networks, and volumes
docker-compose down -v
docker-compose up -d
# In docker-compose.yml
new-service:
image: your-image
networks:
- monitoring
restart: unless-stopped
read_only: true
Edit prometheus/prometheus.yml
to add:
Contributions are welcome! Please:
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is open source and available under the MIT License.