This project sets up a Flask API with Prometheus metrics and Grafana dashboards using Docker Compose.
The API provides a machine learning model prediction endpoint and exposes metrics for monitoring.
. ├── app │ └── api # Flask API source code ├── prometheus │ └── prometheus.yml # Prometheus configuration ├── docker-compose.yml └── README.md

- Dataset: California Housing Dataset
- Goal: Predict median house prices
- EDA & Training:
- Initial training with Linear Regression and Decision Tree
- Final selected model: Decision Tree Regressor
- Feature Store: Feast
- Data Versioning: DVC
- API Framework: FastAPI (model inference)
- Monitoring: Prometheus (metrics) + Grafana (dashboard)
- Deployment: Dockerized FastAPI app
- Retraining: Watcher detects new files → Webhook triggers retraining
Component | Tool/Framework |
---|---|
Data Versioning | DVC |
Feature Store | Feast |
API | FastAPI |
Monitoring | Prometheus + Grafana |
Deployment | Docker |
Retraining | Watchdog + Webhook |
- Flask API exposing
/predict
endpoint - Exposes Prometheus metrics
- Runs on port 5000
- Uses volume mount for live code reload
- Scrapes metrics from the API
- Configurable via
prometheus/prometheus.yml
- Runs on port 9090
- Provides dashboards for metrics visualization
- Runs on port 3000
- Default admin password:
admin
- Persists data in
grafana-storage
volume
- Network:
monitor-net
— Shared network for all services - Volume:
grafana-storage
— Persistent Grafana data
curl --location 'http://localhost:5000/predict'
--header 'Content-Type: application/json'
--data '{
"MedInc": 8.3252,
"HouseAge": 41.0,
"AveBedrms": 1.02,
"Latitude": 37.88
}'
docker-compose up --build
API → http://localhost:5000
Prometheus → http://localhost:9090
Grafana → http://localhost:3000
Username: admin Password: admin
Add Prometheus as a data source:
Stopping Services
docker-compose down
If you want to run the API manually instead of Docker:
# Navigate to API folder
cd app
cd api
# Create virtual environment
python -m venv venv
venv\Scripts\activate # On Windows
# source venv/bin/activate # On Linux/Mac
# Upgrade pip and install dependencies
pip install --upgrade pip
pip install -r requirements.txt
# Run the API
python app.py