wise-monitoring

byDevops Ninegravity

You are a senior full-stack engineer specializing in Python backend systems and DevOps tooling. Build a production-ready monitoring system in Python using **FastAPI** that covers five core monitoring domains: 1. **Website/Uptime Monitoring** β€” HTTP checks, response time measurement, status code validation, and downtime detection. 2. **Database Storage Monitoring** β€” Track disk usage, collection/table sizes, document/row counts, and storage growth trends; alert when thresholds are exceeded. 3. **Database Outage Detection** β€” Probe database connectivity and query health; detect and report connection failures, timeouts, and replication issues. 4. **Server Monitoring & Utilization** β€” Collect CPU, memory, disk I/O, and network metrics via `psutil`; alert when utilization exceeds defined thresholds. ## Target Databases The system must support monitoring for all of the following databases: - **MongoDB** β€” use `motor` (async) for connectivity checks, storage metrics, collection sizes, document counts, and replica set health. - **PostgreSQL** β€” use `asyncpg` for connectivity checks, table sizes, row counts, and replication lag. - **MySQL / MariaDB** β€” use `aiomysql` for connectivity checks, table sizes, and query health. - **Redis** β€” use `aioredis` for connectivity checks, memory usage, key counts, and eviction metrics. Each database monitor must be implemented as a standalone module so new database types can be added without modifying existing monitors. ## Technical Stack & Requirements - **Framework:** FastAPI (Python) - **Persistence:** Store all check results, historical metrics, and alert logs in MongoDB β€” design schemas to support trend queries over time - **Scheduler:** Use `APScheduler` or `asyncio`-based polling for interval-driven checks; all checks must run asynchronously and never block each other - **Error isolation:** Failures in one monitor must never crash the system β€” implement per-monitor error handling, graceful retries, and structured logging - **Configuration:** Externalize all settings (URLs, connection strings, thresholds, polling intervals) into a `.env` file and `config.py` using `pydantic-settings` ## System Components Build the following as distinct, cleanly separated modules: - **`monitors/`** β€” Individual monitor implementations (`website`, `mongodb`, `postgresql`, `mysql`, `redis`, `server`) - **`scheduler/`** β€” Orchestrates all polling intervals and dispatches monitor runs - **`storage/`** β€” Data access layer for persisting and querying check results and metrics - **`alerting/`** β€” Threshold evaluation and notification dispatch (log-based + webhook stub) - **`api/`** β€” FastAPI routers exposing endpoints to: register monitors, retrieve current status, fetch historical metrics, and acknowledge alerts - **`dashboard/`** β€” A simple HTML/JS status dashboard served by FastAPI showing live monitor states ## Code Quality Standards - Production-level error handling and structured logging throughout (`loguru` or Python `logging`) - Clear docstrings and inline comments explaining each module's responsibility - Pydantic models for all request/response schemas and internal data structures - Basic unit tests for monitor logic using `pytest` and `pytest-asyncio` ## Deliverables Provide the complete project structure, all source files with full working code, a `requirements.txt`, a `.env.example` config file, and setup/run instructions. The system must be runnable locally with `uvicorn`, a running MongoDB instance, and optionally connected target databases.

LoginAlertsLogsSettingsDashboardMonitorsMetrics
Login

Comments (0)

No comments yet. Be the first!

No page designs yet.

The Design Agent will generate JSX pages automatically after user flows are created.

Login: Sign In
Dashboard: View Galaxy Map
Dashboard: Acknowledge Alerts
Monitors: Register Monitor
Settings: Configure Thresholds
Logs: Review Alert Logs