A full-featured system for generating test data, storing it in ClickHouse and visualizing it in Grafana with preconfigured dashboards and alerts.
docker-compose up -d
docker pspython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtpython python_generate_script.py --password changeme
python python_generate_script.py --password changeme --records 10000Open in the browser: http://localhost:3000
- Login: admin
- Password: admin123
- Event rate - activity analysis by day/hour/type
- Errors by type - monitoring errors and problematic users
- Latency monitoring - system performance (avg, p95, p99)
- Error anomalies - detecting error spikes and patterns
- High Latency Alert - fires when latency > 2000 ms
- High Error Rate Alert - fires when error_rate > 5%
clickhouse-grafana/
├── docker-compose.yaml
├── python_generate_script.py
├── requirements.txt
├── README.md
└── grafana/
├── provisioning/
│ ├── datasources/
│ │ └── clickhouse.yaml
│ ├── dashboards/
│ │ └── default.yaml
│ └── alerting/
│ └── alerts.yaml
└── dashboards/
├── events_frequency.json
├── errors_by_type.json
├── latency_monitoring.json
└── error_anomalies.json
python python_generate_script.py --password changeme --recreate --records 100000
python python_generate_script.py --password changeme --time-range 24 --records 1000000
python python_generate_script.py --password changeme --skip-create --records 50000docker-compose down
docker-compose down -v
docker-compose logs -f grafana
docker-compose logs -f clickhouse
docker-compose restart grafanadocker exec -it clickhouse clickhouse-client --password changeme
SELECT count() FROM web_events;
SELECT event, count() FROM web_events GROUP BY event;
SELECT avg(latency) FROM web_events;- Docker and Docker Compose
- Python 3.8+
- 2GB+ free RAM for Docker
The web_events table contains:
event_time(DateTime) - event timeevent(String) - event type: login, logout, click, purchase, error, viewuser_id(UInt32) - user ID (1-10000)latency(UInt32) - latency in ms (10-1000)error_type(String) - error type: timeout, server_error, validation_error or empty
- Open the "Latency monitoring" dashboard
- Check P95 and Max latency metrics
- Look at the top users with high latency
- Open the "Errors by type" dashboard
- Check the error rate (should be < 5%)
- Review error trends over time
- Open the "Error anomalies" dashboard
- Check the heatmap to spot patterns
- Compare current values with previous periods
- Check that ClickHouse is running:
docker ps - Make sure the data is loaded (see commands above)
- Check the datasource in Grafana: Settings → Data sources
- Make sure the ClickHouse plugin is installed (check Grafana logs)
- Go to Alerting → Alert rules to check status
- Restart Grafana if needed:
docker-compose restart grafana