Skip to content

feat: add System Status page with Celery queue monitoring and purge#14349

Open
valentijnscholten wants to merge 1 commit intoDefectDojo:devfrom
valentijnscholten:feature/celery-queue-status-ui
Open

feat: add System Status page with Celery queue monitoring and purge#14349
valentijnscholten wants to merge 1 commit intoDefectDojo:devfrom
valentijnscholten:feature/celery-queue-status-ui

Conversation

@valentijnscholten
Copy link
Member

@valentijnscholten valentijnscholten commented Feb 19, 2026

Summary

  • New System Status page (/system_status) accessible to superusers from the navigation menu, alongside System Settings. Displays Celery worker liveness, pending queue length, and active task timeout/expiry settings.
  • Purge queue button to remove all pending tasks (with a warning about re-running deduplication via python manage.py dedupe). Reloads the page after a successful purge.
  • Two new superuser-only REST API endpoints (same permission guards as SystemSettingsViewSet):
    • GET /api/v2/celery/status/ — worker status, queue length, and task config
    • POST /api/v2/celery/queue/purge/ — purge all pending tasks from the broker queue
  • Fix get_celery_worker_status() to use app.control.ping() via Celery's pidbox control channel instead of dispatching a task. The old approach would hang indefinitely when the task queue was clogged.
  • New environment variables in settings.dist.py:
    • DD_CELERY_TASK_TIME_LIMIT (default: 43200 = 12 h) — hard kill via SIGKILL after this many seconds
    • DD_CELERY_TASK_SOFT_TIME_LIMIT (default: disabled) — raises SoftTimeLimitExceeded for graceful cleanup
    • DD_CELERY_TASK_DEFAULT_EXPIRES (default: 43200 = 12 h) — silently discard tasks that have been waiting in the queue longer than this before any worker picks them up
  • Client-side AJAX rendering of the status panel so that dojo-pro can consume the same API endpoints without duplicating the view logic.
  • Refresh button
Screenshot 2026-02-19 204310 Screenshot 2026-02-19 204317 Screenshot 2026-02-19 204329

@github-actions github-actions bot added settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 ui labels Feb 19, 2026
@valentijnscholten valentijnscholten added this to the 2.56.0 milestone Feb 19, 2026
Copy link
Contributor

@Maffooch Maffooch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start! Would it be possible to iterate over the task names, and get a count of those currently queued? That would allow for easier debugging into where bottlenecks are

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this, and add an entry to .gitignore to prevent it from coming in again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, good find.

- Add dedicated System Status page (/system_status) with superuser-only
  access, accessible from the navigation menu alongside System Settings
- Display Celery worker liveness, pending queue length with human-readable
  duration formatting, and active task timeout/expiry configuration
- Add Purge queue button that POSTs to the new API endpoint and reloads
  the page on success
- Fix get_celery_worker_status() to use app.control.ping() via the
  pidbox control channel, which works correctly even when the task queue
  is clogged (previously dispatched a task that would never be picked up)
- Add purge_celery_queue() utility using a direct broker connection
- Add two new superuser-only REST API endpoints:
    GET  /api/v2/celery/status/       - worker status, queue length, config
    POST /api/v2/celery/queue/purge/  - purge all pending tasks
  Both use the same permission guards as SystemSettingsViewSet
  (IsSuperUser + DjangoModelPermissions against System_Settings)
- Add DD_CELERY_TASK_TIME_LIMIT (default 12h), DD_CELERY_TASK_SOFT_TIME_LIMIT
  (default disabled), and DD_CELERY_TASK_DEFAULT_EXPIRES (default 12h)
  environment variables to settings.dist.py with explanatory comments
- Move celery status rendering from server-side Django view to client-side
  AJAX so dojo-pro can consume the same API endpoints

feat: add Refresh button next to Purge button on System Status page

remove plan
@valentijnscholten valentijnscholten force-pushed the feature/celery-queue-status-ui branch from c29ee67 to 73f690b Compare February 26, 2026 08:04
@valentijnscholten
Copy link
Member Author

This is a great start! Would it be possible to iterate over the task names, and get a count of those currently queued? That would allow for easier debugging into where bottlenecks are

Redis doesn't provide a lightweight way to do this. The implementation would have to iterate over all entries in the queue and get the task name & count them. I didn't add that as it would be slow probably for clogged instances. But I could do a test to see if it's acceptable and put this behind a "Statistics" button to trigger it only when the user needs the extra level of detail.

@Maffooch Maffooch modified the milestones: 2.56.0, 2.57.0 Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apiv2 settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants