https://github.com/tyronejosee/prototype_metrics
Prototype for a complete Grafana and Prometheus monitoring setup, orchestrated with Docker Compose for easy deployment and configuration.
https://github.com/tyronejosee/prototype_metrics
docker-compose grafana json metrics prometheus python yaml
Last synced: 3 months ago
JSON representation
Prototype for a complete Grafana and Prometheus monitoring setup, orchestrated with Docker Compose for easy deployment and configuration.
- Host: GitHub
- URL: https://github.com/tyronejosee/prototype_metrics
- Owner: tyronejosee
- License: mit
- Created: 2025-07-29T23:45:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-28T04:11:33.000Z (9 months ago)
- Last Synced: 2025-09-28T06:10:44.103Z (9 months ago)
- Topics: docker-compose, grafana, json, metrics, prometheus, python, yaml
- Language: Python
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Prototype Metrics
Complete Grafana + Prometheus monitoring setup with Docker Compose, designed for learning and experimentation.


## ๐๏ธ Architecture Overview
- **Grafana**: Web interface for creating dashboards and visualizing metrics
- **Prometheus**: Time-series database that stores metrics
- **Pushgateway**: Allows batch jobs to push metrics to Prometheus
- **Python Script**: Generates realistic system metrics
## ๐ Quick Start Guide
Prerequisites
- Docker and Docker Compose installed
- Python 3.7+ (for the metric generator script)
Start the Services
```bash
# Start all services in the background
docker compose up -d
# Check if all services are running
docker compose ps
```
Install Python Dependencies
> Recommended to use [uv](https://docs.astral.sh/uv/guides/install-python/#getting-started).
```bash
uv sync
```
Run the Metric Generator
```bash
uv run metric_generator.py
```
Access the Services
- **Grafana**:
- Username: `admin`
- Password: `admin123`
- **Prometheus**:
- **Pushgateway**:
## ๐ Pre-configured Dashboard
The setup includes a pre-configured dashboard called "System Metrics Dashboard" that displays:
- CPU Usage
- Memory Usage
- Request Count
- Error Count
## ๐ ๏ธ Customization Ideas
Adding New Metrics
1. Modify `metric_generator.py` to include new metrics
2. Update the dashboard JSON or create new panels in Grafana UI
Different Data Sources
- Replace Prometheus with InfluxDB for different time-series storage
- Add Loki for log aggregation
- Include Node Exporter for real system metrics
Advanced Features
- Set up alerting rules in Prometheus
- Add notification channels in Grafana
- Create custom alert conditions
## ๐งช Testing and Development
View Raw Metrics
Visit to see raw metrics from Pushgateway
Query Metrics in Prometheus
Go to and try these queries:
- `cpu_usage_percent`
- `memory_usage_percent`
- `rate(request_count_total[5m])`
Stop Everything
```bash
docker-compose down
# Remove volumes (caution: this deletes all data)
docker-compose down -v
```
## ๐ File Structure
```bash
prototype_grafana_prometheus/
โโโ docker-compose.yml # Main orchestration file
โโโ prometheus/
โ โโโ prometheus.yml # Prometheus configuration
โโโ datasources/
โ โโโ prometheus.yml # Grafana datasource config
โโโ dashboards/
โ โโโ dashboard.yml # Dashboard provider config
โ โโโ system-metrics.json # Pre-built dashboard
โโโ metric_generator.py # Metric generation script
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
```
## ๐ง Troubleshooting
Services won't start
- Check Docker is running: `docker ps`
- Check logs: `docker-compose logs [service-name]`
No data in Grafana
- Verify Prometheus is scraping:
- Check if metrics are being pushed:
- Ensure the Python script is running without errors
Can't access Grafana
- Wait a few minutes for services to fully start
- Check if port 3000 is available: `netstat -an | grep 3000`
## โ๏ธ License
This project is licensed under the [MIT License](LICENSE).
Enjoy! ๐