Skip to main content

Real-time monitoring UI for Async TasQ

Project description

Async TasQ Monitor

Tests Coverage Python Version PyPI Version License: MIT

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

  1. 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:

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 updates
  • tasks - Task list updates (new, completed, failed)
  • task:{id} - Specific task updates
  • workers - Worker list updates
  • worker:{id} - Specific worker updates
  • queues - Queue list updates
  • queue:{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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asynctasq_monitor-0.9.2.tar.gz (421.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asynctasq_monitor-0.9.2-py3-none-any.whl (457.3 kB view details)

Uploaded Python 3

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

Hashes for asynctasq_monitor-0.9.2.tar.gz
Algorithm Hash digest
SHA256 0427b5a95579adace4b0bfb447602eeaf37c8e875d733c74ba739e6a91d23545
MD5 2bf07558faa1ab1eaf0ca12ac729d808
BLAKE2b-256 5896e19dbc8e3badf71833fc2cd072a1e1531afe389d8fb9f639777a4ebc32e1

See more details on using hashes here.

File details

Details for the file asynctasq_monitor-0.9.2-py3-none-any.whl.

File metadata

File hashes

Hashes for asynctasq_monitor-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 209f3dc8579da81e85ca49c78eb243b22ef0ddc6da28c11a2a93a89d625f27a1
MD5 c873b60606d88eee90029956d2516e52
BLAKE2b-256 6dfeae24252d9f790d265e23485e10945028f6d099a3e6d6c3586a6a987f2585

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page