A debugging dashboard for FastAPI applications with real-time monitoring
Project description
FastAPI Radar
A debugging dashboard for FastAPI applications providing real-time request, database query, and exception monitoring.
Just one line to add powerful monitoring to your FastAPI app!
See it in Action
Installation
pip install fastapi-radar
Or with your favorite package manager:
# Using poetry
poetry add fastapi-radar
# Using pipenv
pipenv install fastapi-radar
Note: The dashboard comes pre-built! No need to build anything - just install and use.
Quick Start
With SQL Database (Full Monitoring)
from fastapi import FastAPI
from fastapi_radar import Radar
from sqlalchemy import create_engine
app = FastAPI()
engine = create_engine("sqlite:///./app.db")
# Full monitoring with SQL query tracking
radar = Radar(app, db_engine=engine)
radar.create_tables()
# Your routes work unchanged
@app.get("/users")
async def get_users():
return {"users": []}
Without SQL Database (HTTP & Exception Monitoring)
from fastapi import FastAPI
from fastapi_radar import Radar
app = FastAPI()
# Monitor HTTP requests and exceptions only
# Perfect for NoSQL databases, external APIs, or database-less apps
radar = Radar(app) # No db_engine parameter needed!
radar.create_tables()
@app.get("/api/data")
async def get_data():
# Your MongoDB, Redis, or external API calls here
return {"data": []}
Access your dashboard at: http://localhost:8000/\_\_radar/
Features
- Zero Configuration - Works with any FastAPI app (SQL database optional)
- Request Monitoring - Complete HTTP request/response capture with timing
- Database Monitoring - SQL query logging with execution times (when using SQLAlchemy)
- Exception Tracking - Automatic exception capture with stack traces
- Real-time Updates - Live dashboard updates as requests happen
- Flexible Integration - Use with SQL, NoSQL, or no database at all
Configuration
radar = Radar(
app,
db_engine=engine, # Optional: SQLAlchemy engine for SQL query monitoring
dashboard_path="/__radar", # Custom dashboard path (default: "/__radar")
max_requests=1000, # Max requests to store (default: 1000)
retention_hours=24, # Data retention period (default: 24)
slow_query_threshold=100, # Mark queries slower than this as slow (ms)
capture_sql_bindings=True, # Capture SQL query parameters
exclude_paths=["/health"], # Paths to exclude from monitoring
theme="auto", # Dashboard theme: "light", "dark", or "auto"
db_path="/path/to/db", # Custom path for radar.duckdb file (default: current directory)
)
Custom Database Location
By default, FastAPI Radar stores its monitoring data in a radar.duckdb file in your current working directory. You can customize this location using the db_path parameter:
# Store in a specific directory
radar = Radar(app, db_path="/var/data/monitoring")
# Creates: /var/data/monitoring/radar.duckdb
# Store with a specific filename
radar = Radar(app, db_path="/var/data/my_app_monitoring.duckdb")
# Creates: /var/data/my_app_monitoring.duckdb
# Use a relative path
radar = Radar(app, db_path="./data")
# Creates: ./data/radar.duckdb
If the specified path cannot be created, FastAPI Radar will fallback to using the current directory with a warning.
Development Mode with Auto-Reload
When running your FastAPI application with fastapi dev (which uses auto-reload), FastAPI Radar automatically switches to an in-memory database to avoid file locking issues. This means:
- No file locking errors - The dashboard will work seamlessly in development
- Data doesn't persist between reloads - Each reload starts with a fresh database
- Production behavior unchanged - When using
fastapi runor deploying, the normal file-based database is used
# With fastapi dev (auto-reload enabled):
# Automatically uses in-memory database - no configuration needed!
radar = Radar(app)
radar.create_tables() # Safe to call - handles multiple processes gracefully
This behavior only applies when using the development server with auto-reload (fastapi dev). In production or when using fastapi run, the standard file-based DuckDB storage is used.
What Gets Captured?
- ✅ HTTP requests and responses
- ✅ Response times and performance metrics
- ✅ SQL queries with execution times
- ✅ Query parameters and bindings
- ✅ Slow query detection
- ✅ Exceptions with stack traces
- ✅ Request/response bodies and headers
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
For contributors who want to modify the codebase:
- Clone the repository:
git clone https://github.com/doganarif/fastapi-radar.git
cd fastapi-radar
- Install development dependencies:
pip install -e ".[dev]"
- (Optional) If modifying the dashboard UI:
cd fastapi_radar/dashboard
npm install
npm run dev # For development with hot reload
# or
npm run build # To rebuild the production bundle
- Run the example apps:
# Example with SQL database
python example_app.py
# Example without SQL database (NoSQL/in-memory)
python example_nosql_app.py
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_radar-0.3.1.tar.gz.
File metadata
- Download URL: fastapi_radar-0.3.1.tar.gz
- Upload date:
- Size: 594.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26456c0606f8b0ff3e4c2f2d990156737ac1c7434e2a57e37527c1ff0dc9eb30
|
|
| MD5 |
dd7e80b47c495700665cc0ca8749f381
|
|
| BLAKE2b-256 |
70228cbfa8e58867f4d9ede77c4d8dd88bbb9248d334e02dea276194be0a9090
|
File details
Details for the file fastapi_radar-0.3.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_radar-0.3.1-py3-none-any.whl
- Upload date:
- Size: 593.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
643f3c3d4e35c241cb940a4f7a7aa5ad4a5de1654180c9e06689b18ef53e4c4e
|
|
| MD5 |
2b6c82cbd36b4ff78d498a4bd5625cbd
|
|
| BLAKE2b-256 |
672eb0b26004c701a2ea25019032b63b21e889630bd2a584168d018a56dcdede
|