This project demonstrates a production-ready FastAPI setup with monitoring and logging capabilities.
- FastAPI backend with structured logging
- Prometheus metrics integration
- Grafana dashboards for visualization
- Docker and Docker Compose setup
- Built-in health checks and monitoring endpoints
- Docker and Docker Compose
- Python 3.9+ (for local development)
- Clone the repository
- Run the stack:
docker-compose up --build
- FastAPI Application: http://localhost:8000
- FastAPI Swagger Docs: http://localhost:8000/docs
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
- Application Health: http://localhost:8000/health
- Metrics: http://localhost:8000/metrics
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
python src/main.py
The application uses structured logging with the following features:
- Request/response logging with timing
- JSON format for easy parsing
- Correlation IDs for request tracking
The following metrics are available:
- Request latency
- Request counts by endpoint
- HTTP status codes
- System metrics (CPU, memory)