A lightweight, containerized tool for real-time database performance monitoring and query analytics. Built with FastAPI and Python, it connects to Oracle DB, tracks long-running queries, logs performance metrics, and serves them over RESTful APIs. Visualize data with Grafana or extend it with Prometheus integration.
- 📡 Monitors Oracle DB performance (query time, session state)
- 🌐 REST APIs via FastAPI
- 🗃 Logs slow and long-running queries
- 📈 Compatible with Grafana dashboards
- 🔧 Easily extendable, lightweight design
- 🐳 Runs fully in Docker
- FastAPI + Python
- sqlalchemy for Oracle DB connection
- SQLite for storing historical metrics
- Docker for deployment
db_monitor/
├── app/
│ ├── main.py # FastAPI routes
│ ├── db.py # Oracle DB connector
│ ├── metrics.py # Metrics logic
│ ├── models.py # SQLite models
│ └── logging.conf # Logging config
├── Dockerfile
├── requirements.txt
└── README.md
- Clone the repository:
git clone https://github.com/yourusername/db-monitor.git
cd db-monitor- Build the Docker image:
docker build -t db_monitor .- Run the container:
docker run -p 8000:8000 db_monitorThe app uses hardcoded Oracle credentials inside db.py for demonstration purposes. No environment variables or additional setup is required.
- Open API Docs:
http://localhost:8000/metrics/slow_queries
http://localhost:8000/metrics/long_transactions
| Method | Endpoint | Description |
|---|---|---|
| GET | /metrics/slow_queries | Returns slow SQL queries |
| GET | /metrics/long_transactions | Returns sessions with long transactions |
- Quick diagnostics of Oracle DB performance
- Prototyping custom metrics exporters
- Hands-on demo for SREs and DBAs
Created for educational and prototyping use. Extend as needed for production.