Skip to main content

An Alliance Auth app for monitoring celery tasks.

Project description

Task Monitor

An Alliance Auth app for monitoring celery tasks.

release python django pipeline codecov license pre-commit Code style: black chat

Contents

Features

Task Monitor enables administrators to monitor celery tasks running on their system.

  • Creates a log of all recently executed celery tasks including failed and retried tasks.
  • Stores many details in task logs to support the analysis of potential celery issues, including the parameters a task with called with and complete exception messages
  • Keeps the storage needs in check by automatically deleting older task logs and removing likely bloat from the collected data (but can also be turned off)
  • Admins can investigate task log with search & filters
  • Admins can view details for each task incl. exceptions and trace logs
  • Admins can review reports with charts providing answers to common questions, e.g:
    • How many tasks have failed/retried?
    • How many tasks where run by each of my apps?
    • Which are the most frequent tasks?
    • Which tasks have the longest runtime?
    • Which tasks failed the most?
    • How much backlog do I have in task queue over time?
  • Admins can export all task logs to a CSV file for further analysis with 3rd party tools (e.g. Google sheets)
  • Command line utility to manage task logs and queue directly

Screenshots

Full log of all recently executed tasks

tasklog

View details for each task incl. exception tracelogs

tasklog

Example chart in reports

tasklog

Installation

Step 1 - Check prerequisites

Task Monitor is a plugin for Alliance Auth. If you don't have Alliance Auth running already, please install it first before proceeding. (see the official AA installation guide for details)

Step 2 - Install app

Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:

pip install aa-taskmonitor

Step 3 - Configure Auth settings

Configure your Auth settings (local.py) as follows:

  • Add 'taskmonitor' to INSTALLED_APPS
  • Optional: Add additional settings if you want to change any defaults. See Settings for the full list.

Step 4 - Finalize App installation

Run migrations & copy static files

python manage.py migrate
python manage.py collectstatic --noinput

Restart your supervisor services for Auth.

Command line utility

You can manage your logs and queue also directly via a command line utility.

The basic syntax for using the utility is:

python manage.py taskmonitorctl {command} {target}

For example you can inspect your logs with:

python manage.py taskmonitorctl inspect logs

Or for example you can purge your task queue with:

python manage.py taskmonitorctl purge queue

To get an overview of available commands run:

python manage.py taskmonitorctl --help

To get an overview of available targets for a command run:

python manage.py taskmonitorctl inspect --help

Settings

Here is a list of available settings for this app. They can be configured by adding them to your AA settings file (local.py).

Note that all settings are optional and the app will use the documented default settings if they are not used.

Name Description Default
TASKMONITOR_ENABLED Global switch to enable/disable task monitor. True
TASKMONITOR_DATA_MAX_AGE Max age of logged tasks in hours. Older logs be deleted automatically. 24
TASKMONITOR_DELETE_STALE_BATCH_SIZE Size of task logs deleted together in one batch. 5_000
TASKMONITOR_HOUSEKEEPING_FREQUENCY Frequency of house keeping runs in minutes. 15
TASKMONITOR_QUEUED_TASKS_CACHE_TIMEOUT Timeout for caching queued tasks in seconds. 10
TASKMONITOR_QUEUED_TASKS_ADMIN_LIMIT The admin page will stop showing the list of queued tasks above this limit to protect against crashing caused by too high memory consumption. 100_000
TASKMONITOR_REPORTS_MAX_AGE Max age of cached reports in minutes. 30
TASKMONITOR_REPORTS_MAX_TOP Max items to show in the top reports. e.g. 10 will shop the top ten items. 15
TASKMONITOR_TRUNCATE_NESTED_DATA Whether deeply nested task params and results are truncated. Please see FAQ for details. True

FAQ

Is it possible to store task logs longer then for just 24 hours?

Yes, there is a setting, which you can increase according to your needs. However, please keep in mind that your storage needs will increase accordingly. The current approx. usage is 0.5 KB per entry, so e.g. you need approx. 500 MB to store 1.000.000 task logs. Note that you can use the command line utility to find out how much space your logs are currently using.

How is this app different from celery analytics?

Celery Analytics seams to be designed mainly as data source for reports on Grafana. It apparently works great if you want to integrate analysis about your task executions into a Grafana dashboards. But it's usability without Grafana is limited.

Task Monitor on the other hand aims to be fully functional standalone by providing reports and many useful features for analyzing your task logs directly on the admin site. It also provides a more complete picture, since Celery Analytics ignores retried tasks.

How is this app different from celery's flower?

Flower offers more detailed and technical information about task runs and might therefore be more most for developers. However, it not designed to store a larger number of task logs (default is only 10K) and is appears therefore to be less suited for Alliance Auth, where you typically have 100K+ tasks per day.

What does data truncating do exactly?

Task Monitor has data truncating enabled by default. It is applied when storing args, kwargs and results in task logs. This helps to reduce the storage consumptions and also makes the task log better readable. But it can be turned off.

Task args are truncated by clearing all nested containers.

Example: [1, [2, 3], 4] becomes [1, [], 4]

Task kwargs are truncated by clearing all nested containers in values.

Example: {"a": [1, 2], "b": 3} becomes {"a": [], "b": 3}

Finally, task results are truncated like args and kwargs depending on their type. In addition lists of empty containers are compressed.

Example: [ [], [], [] ] becomes []

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

aa_taskmonitor-0.20.0.tar.gz (452.9 kB view details)

Uploaded Source

Built Distribution

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

aa_taskmonitor-0.20.0-py3-none-any.whl (476.3 kB view details)

Uploaded Python 3

File details

Details for the file aa_taskmonitor-0.20.0.tar.gz.

File metadata

  • Download URL: aa_taskmonitor-0.20.0.tar.gz
  • Upload date:
  • Size: 452.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for aa_taskmonitor-0.20.0.tar.gz
Algorithm Hash digest
SHA256 61b147c4d3eb7e854a95b8555895c26fd98d5758e129a5ee0e6725e5a7403f99
MD5 6cc3f74a6acf046b530f33c884e7017b
BLAKE2b-256 6bacf1afe0e2f6b6700b34f8a33633fa34e3b4369c39f29baa29f2d0bdb41460

See more details on using hashes here.

File details

Details for the file aa_taskmonitor-0.20.0-py3-none-any.whl.

File metadata

  • Download URL: aa_taskmonitor-0.20.0-py3-none-any.whl
  • Upload date:
  • Size: 476.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for aa_taskmonitor-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5b93db295dc0d2be5e9eb8ff5ee158c306fab89e16395509657d20f914848c7
MD5 02f9f6b326d8b698c95b7b3202b0fd44
BLAKE2b-256 4afff3f963dda091a8f9d9c9a395446f48e2c7408aa5a1b18581b03f04c6762a

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