ShopatPro
Published on

FastAPI Celery UI – Real-Time Task & Worker Monitoring Dashboard

Authors

🚀 FastAPI Celery UI - Comprehensive Monitoring Dashboard

Comprehensive, persistent monitoring for Celery tasks & workers — built with FastAPI.

Contents:

✨ Features

  • Real-time Worker & Service Status: Displays total Celery services and active workers via Celery introspection.
  • Detailed Task Monitoring:
    • Task ID – unique identifier.
    • Task Name – function name.
    • StatusPENDING, STARTED, SUCCESS, FAILURE.
    • Timingeta and runtime.
    • Details – args/kwargs and tracebacks for failures.
  • Persistent Logging & History: Stores all task details in a DB (SQLite by default).
  • Dynamic UI with Auto-Refresh: Configurable auto-update interval.
  • Asynchronous & Efficient: Built with FastAPI, SQLAlchemy, and aiosqlite.

🛠️ Installation

  1. Clone:
    git clone https://github.com/aimldevs/celery-ui.git
    cd celery-ui
  2. Create venv:
    # macOS/Linux
    python3 -m venv venv
    source venv/bin/activate
    
    # Windows
    python -m venv venv
    venv\Scripts\activate
  3. Install:
    pip install -r requirements.txt
  4. Environment variables (optional):
    Variable Description Default
    REDIS_URL Redis broker URL redis://localhost:6379/0
    CELERY_RESULT_URL Redis result backend redis://localhost:6379/1
    DATABASE_URL SQLAlchemy DB URL sqlite+aiosqlite:///./celery_ui.db
    UI_REFRESH_SECONDS UI auto-refresh (sec) 2
  5. Migrations:
    alembic upgrade head

🚀 Running the Application

  1. Start Celery workers:
    celery -A your_celery_app_file worker --loglevel=info
  2. Start FastAPI:
    uvicorn main:app --reload
  3. Open UI: http://localhost:8000

🐳 Using Docker

docker run -d \
  -p 8000:8000 \
  -e REDIS_URL='redis://host.docker.internal:6379/0' \
  -e CELERY_RESULT_URL='redis://host.docker.internal:6379/1' \
  -e DATABASE_URL='sqlite+aiosqlite:///./celery_ui.db' \
  --name celery-ui \
  aimldevs/celery-ui

Note: host.docker.internal maps to the host machine from inside the container.

🤝 Celery Integration

The UI reads the Redis result backend (CELERY_RESULT_URL), persists results to the configured DB, and provides historical views beyond Redis eviction.