Real-time monitoring UI for Async TasQ
Project description
Async TasQ Monitor
Real-time monitoring UI for asynctasq task queues. Available as both a web dashboard (browser-based) and a TUI (terminal-based) interface.
Requirements
- Python 3.12+
- Redis Server: A running Redis server is required for real-time event streaming via Pub/Sub
Features
Web Interface (Browser-based)
- ๐ Real-time Dashboard - Live task, worker, and queue metrics with auto-refresh
- ๐ Task Management - View, filter, search, retry, and cancel tasks
- ๐ท Worker Monitoring - Track worker status, health, and performance
- ๐ Queue Analytics - Monitor queue depths, throughput, and processing rates
- ๐ Metrics & Charts - Visualize trends with Recharts-powered graphs
- ๐ WebSocket Updates - Automatic real-time updates via WebSocket connections
- โจ๏ธ Keyboard Shortcuts - Navigate efficiently with keyboard controls
- ๐จ Modern UI - Built with React 19, TailwindCSS 4, React Aria, and Tanstack Query
- ๐ Dark/Light Theme - Toggle between themes for comfortable viewing
TUI Interface (Terminal-based)
- ๐ฅ๏ธ Terminal Dashboard - Full monitoring in your terminal, perfect for SSH sessions
- โจ๏ธ Keyboard-driven - Navigate with vim-style keybindings
- ๐ Real-time Updates - Live event streaming directly in the terminal
- ๐จ Rich UI - Built with Textual framework for beautiful terminal graphics
Installation
The monitor is available in three installation variants:
# Core package (required)
uv add asynctasq-monitor # or: pip install asynctasq-monitor
# With web UI (FastAPI + React dashboard)
uv add "asynctasq-monitor[web]" # or: pip install "asynctasq-monitor[web]"
# With TUI (terminal interface)
uv add "asynctasq-monitor[tui]" # or: pip install "asynctasq-monitor[tui]"
# Everything included
uv add "asynctasq-monitor[all]" # or: pip install "asynctasq-monitor[all]"
Alternatively, install as an extra from the core asynctasq package:
uv add "asynctasq[monitor]" # or: pip install "asynctasq[monitor]"
Note: All installation methods include
redis[hiredis]for high-performance Redis Pub/Sub communication.
Quick Start
Prerequisites
- Redis Server: Ensure Redis is running and accessible (default:
redis://localhost:6379)
Configure Your Workers
Configure your task workers to emit events to Redis:
from asynctasq import set_global_config
# Option 1: Use Redis as queue driver (events enabled automatically)
set_global_config(driver="redis", redis_url="redis://localhost:6379")
# Option 2: Use another driver but still emit events to Redis
set_global_config(driver="postgres", redis_url="redis://localhost:6379")
Run the Web Monitor
# Start the web monitor server
asynctasq-monitor web
# With custom options
asynctasq-monitor web --host 0.0.0.0 --port 8080
# With auto-reload for development
asynctasq-monitor web --reload --log-level debug
Then open http://localhost:8000 in your browser.
Run the TUI Monitor
# Start the terminal UI
asynctasq-monitor tui
# With custom Redis URL
asynctasq-monitor tui --redis-url redis://localhost:6379
# With custom refresh rate
asynctasq-monitor tui --refresh-rate 0.5
Embed in Your FastAPI App
from fastapi import FastAPI
from asynctasq_monitor import create_monitoring_app
# Create a standalone monitoring app
monitor_app = create_monitoring_app()
# Or mount it in your existing app
app = FastAPI()
app.mount("/monitor", create_monitoring_app())
CLI Reference
The CLI uses subcommands for different interfaces:
asynctasq-monitor [OPTIONS] COMMAND [ARGS]
Global Options:
-v, --verbose Enable verbose output
--config PATH Path to config file (TOML)
--help Show help message
Commands:
web Start the web-based monitor UI
tui Start the terminal-based monitor UI
Web Command
asynctasq-monitor web [OPTIONS]
Options:
--host TEXT Host to bind to (default: 127.0.0.1)
Env: MONITOR_HOST
--port INTEGER Port to bind to (default: 8000)
Env: MONITOR_PORT
--reload Enable auto-reload for development
--workers INTEGER Number of worker processes (default: 1)
--log-level TEXT Log level: debug, info, warning, error, critical
TUI Command
asynctasq-monitor tui [OPTIONS]
Options:
--redis-url TEXT Redis connection URL (default: redis://localhost:6379)
Env: ASYNCTASQ_REDIS_URL
--theme TEXT Color theme: dark or light (default: dark)
--refresh-rate FLOAT Refresh rate in seconds (default: 1.0, range: 0.1-60.0)
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
MONITOR_HOST |
Host address for the web server | 127.0.0.1 |
MONITOR_PORT |
Port for the web server | 8000 |
MONITOR_DEBUG |
Enable debug mode | false |
MONITOR_CORS_ORIGINS |
Comma-separated CORS origins | * |
MONITOR_ENABLE_AUTH |
Enable JWT authentication | false |
MONITOR_SECRET_KEY |
Secret key for JWT (min 32 chars) | - |
MONITOR_POLLING_INTERVAL_SECONDS |
Metric polling interval | 5 |
MONITOR_WEBSOCKET_HEARTBEAT_SECONDS |
WebSocket ping interval | 30 |
MONITOR_METRICS_RETENTION_DAYS |
Historical metrics retention | 90 |
MONITOR_LOG_LEVEL |
Logging level | INFO |
ATQ_REDIS_URL |
Redis URL for event consumer | redis://localhost:6379 |
ATQ_EVENTS_CHANNEL |
Redis Pub/Sub channel | asynctasq:events |
API Documentation
When running the web monitor, interactive API documentation is available at:
- Swagger UI: http://localhost:8000/api/docs
- ReDoc: http://localhost:8000/api/redoc
REST API Endpoints
| Endpoint | Description |
|---|---|
GET /api/dashboard/summary |
Dashboard overview with key metrics |
GET /api/tasks |
List tasks with filtering and pagination |
GET /api/tasks/{id} |
Get task details |
POST /api/tasks/{id}/retry |
Retry a failed task |
POST /api/tasks/{id}/cancel |
Cancel a pending task |
GET /api/workers |
List workers with status |
GET /api/workers/{id} |
Get worker details |
GET /api/queues |
List queues with metrics |
GET /api/metrics |
Get detailed metrics |
WebSocket API
Connect to ws://localhost:8000/ws for real-time updates.
Room Subscriptions:
ws://localhost:8000/ws?rooms=global # Dashboard updates
ws://localhost:8000/ws?rooms=tasks&rooms=workers # Multiple rooms
ws://localhost:8000/ws?rooms=task:abc123 # Specific task updates
Available Rooms:
global- Dashboard overview updatestasks- Task list updates (new, completed, failed)task:{id}- Specific task updatesworkers- Worker list updatesworker:{id}- Specific worker updatesqueues- Queue list updatesqueue:{name}- Specific queue updates
Client Commands:
{"action": "subscribe", "room": "task:abc123"}
{"action": "unsubscribe", "room": "task:abc123"}
{"action": "ping"}
Development
Prerequisites
- Python 3.12+
- Node.js 24+
- uv (Python package manager)
- pnpm (Frontend package manager)
- just (Command runner)
Setup
# Clone the repository
git clone https://github.com/adamrefaey/asynctasq-monitor.git
cd asynctasq-monitor
# Initialize the project (installs all dependencies + pre-commit hooks)
just init
# Or manually:
uv sync --all-extras # Python dependencies
cd frontend && pnpm install # Frontend dependencies
Development Servers
# Run backend with auto-reload (http://localhost:8000)
just dev-backend
# Run frontend with hot-reload (http://localhost:5173)
just dev-frontend
Available Commands
Run just to see all available commands. Key commands:
# Development
just dev-backend # Start backend with auto-reload
just dev-frontend # Start frontend with hot-reload
# Building
just build-frontend # Build frontend into Python package
just build # Build both frontend and Python package
just release # Full release build (clean + build)
# Testing
just test # Run all tests (backend + frontend)
just test-backend # Run Python tests
just test-frontend # Run frontend tests
just test-unit # Run unit tests only
just test-cov # Run tests with coverage report
# Code Quality
just format # Format all code (Python + TypeScript)
just lint # Lint all code
just lint-fix # Auto-fix linting issues
just typecheck # Type check Python with Pyright
just typecheck-frontend # Type check frontend with TypeScript
just check # Run all checks (format, lint, typecheck)
# Security
just security # Run Bandit security scanner
just audit # Audit dependencies for vulnerabilities
# Docker (for integration tests)
just docker-up # Start test services (Redis, etc.)
just docker-down # Stop test services
# Publishing
just publish # Publish to PyPI
just publish-test # Publish to Test PyPI
just tag v1.2.3 # Create and push a git tag
Architecture
asynctasq-monitor/
โโโ src/
โ โโโ asynctasq_monitor/ # Python package
โ โโโ __init__.py # Package exports (create_monitoring_app)
โ โโโ __main__.py # CLI entry point
โ โโโ config.py # Pydantic Settings configuration
โ โโโ cli/ # Typer CLI commands
โ โ โโโ main.py # Main CLI app with subcommands
โ โ โโโ web.py # Web server command
โ โ โโโ tui.py # TUI command
โ โโโ api/ # FastAPI application
โ โ โโโ main.py # App factory with lifespan
โ โ โโโ dependencies.py # Dependency injection
โ โ โโโ routes/ # API route modules
โ โ โโโ dashboard.py # Dashboard endpoints
โ โ โโโ tasks.py # Task endpoints
โ โ โโโ workers.py # Worker endpoints
โ โ โโโ queues.py # Queue endpoints
โ โ โโโ metrics.py # Metrics endpoints
โ โ โโโ websocket.py # WebSocket endpoint
โ โโโ models/ # Pydantic models
โ โ โโโ task.py # Task models
โ โ โโโ worker.py # Worker models
โ โ โโโ queue.py # Queue models
โ โโโ services/ # Business logic
โ โ โโโ event_consumer.py # Redis Pub/Sub consumer
โ โ โโโ metrics_collector.py
โ โ โโโ prometheus.py # Prometheus exporter
โ โ โโโ task_service.py
โ โ โโโ worker_service.py
โ โ โโโ queue_service.py
โ โโโ websocket/ # WebSocket handling
โ โ โโโ manager.py # Connection management
โ โ โโโ broadcaster.py # Event broadcasting
โ โโโ tui/ # Textual TUI application
โ โ โโโ app.py # Main TUI app
โ โ โโโ event_handler.py # Event consumption
โ โ โโโ screens/ # TUI screens
โ โ โโโ widgets/ # Custom widgets
โ โ โโโ styles/ # TCSS stylesheets
โ โโโ static/ # Built frontend (generated)
โโโ frontend/ # React frontend source
โ โโโ src/
โ โ โโโ main.tsx # App entry point
โ โ โโโ router.tsx # React Router configuration
โ โ โโโ pages/ # Page components
โ โ โ โโโ Dashboard.tsx
โ โ โ โโโ Tasks.tsx
โ โ โ โโโ Workers.tsx
โ โ โ โโโ Queues.tsx
โ โ โ โโโ Metrics.tsx
โ โ โ โโโ Settings.tsx
โ โ โโโ components/ # Reusable components
โ โ โโโ hooks/ # Custom React hooks
โ โ โ โโโ useDashboard.ts
โ โ โ โโโ useTasks.ts
โ โ โ โโโ useWorkers.ts
โ โ โ โโโ useWebSocket.ts # WebSocket with auto-reconnect
โ โ โ โโโ useKeyboardShortcuts.ts
โ โ โโโ lib/ # Utilities
โ โ โโโ api.ts # Type-safe API client
โ โ โโโ types.ts # TypeScript types
โ โโโ package.json
โ โโโ vite.config.ts
โ โโโ tsconfig.json
โ โโโ biome.json # Linting/formatting config
โโโ tests/ # Python tests
โ โโโ unit/
โ โโโ integration/
โ โโโ infrastructure/ # Docker compose for tests
โโโ pyproject.toml
โโโ justfile # Command runner recipes
Tech Stack
Backend
- Python 3.12+ - Modern Python with type hints
- FastAPI - High-performance async web framework
- Typer - CLI framework with Rich support
- Pydantic - Data validation and settings management
- Redis - Event streaming via Pub/Sub
- Textual - Modern TUI framework
Frontend
- React 19 - UI library with new compiler
- TypeScript 5.9 - Type-safe JavaScript
- Vite 7 - Next-generation build tool
- TailwindCSS 4 - Utility-first CSS
- Tanstack Query - Async state management
- Tanstack Table - Headless table component
- React Aria - Accessible UI components
- Recharts - Composable charting library
- React Router 6 - Client-side routing
- Zustand - Lightweight state management
- Vitest - Fast unit testing
- Biome - Fast linting and formatting
License
MIT License - see LICENSE for details.
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 asynctasq_monitor-0.9.2.tar.gz.
File metadata
- Download URL: asynctasq_monitor-0.9.2.tar.gz
- Upload date:
- Size: 421.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0427b5a95579adace4b0bfb447602eeaf37c8e875d733c74ba739e6a91d23545
|
|
| MD5 |
2bf07558faa1ab1eaf0ca12ac729d808
|
|
| BLAKE2b-256 |
5896e19dbc8e3badf71833fc2cd072a1e1531afe389d8fb9f639777a4ebc32e1
|
File details
Details for the file asynctasq_monitor-0.9.2-py3-none-any.whl.
File metadata
- Download URL: asynctasq_monitor-0.9.2-py3-none-any.whl
- Upload date:
- Size: 457.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209f3dc8579da81e85ca49c78eb243b22ef0ddc6da28c11a2a93a89d625f27a1
|
|
| MD5 |
c873b60606d88eee90029956d2516e52
|
|
| BLAKE2b-256 |
6dfeae24252d9f790d265e23485e10945028f6d099a3e6d6c3586a6a987f2585
|