Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psychok7/django-celery-inspect
Django reusable app that uses Celery Inspect command to monitor workers/tasks via the Django REST Framework
https://github.com/psychok7/django-celery-inspect
celery django django-rest-framework inspection monitoring python
Last synced: 17 days ago
JSON representation
Django reusable app that uses Celery Inspect command to monitor workers/tasks via the Django REST Framework
- Host: GitHub
- URL: https://github.com/psychok7/django-celery-inspect
- Owner: psychok7
- License: mit
- Created: 2017-02-18T15:02:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-02-21T17:37:24.000Z (over 7 years ago)
- Last Synced: 2024-10-14T01:45:01.696Z (about 1 month ago)
- Topics: celery, django, django-rest-framework, inspection, monitoring, python
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 41
- Watchers: 4
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# django-celery-inspect
Django reusable-app that uses Celery Inspect command to monitor workers via the [Django REST Framework](https://github.com/tomchristie/django-rest-framework).
The main idea is to be able to monitor celery workers from another external service or server via a REST API and figure out if they are running or not by using celery's own [Inspect API]
(http://docs.celeryproject.org/en/latest/userguide/workers.html#inspecting-workers).## Quick start
1. Install:
pip install django-celery-inspect
2. Add "celery_inspect" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'celery_inspect',
]3. Add the following to your urls.py:
url(r'^api/v1/celery-inspect/', include('celery_inspect.urls', namespace='celery_inspect')),
4. If you Desire to use DRF's Authentication to protect these endpoints (Optional).REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
}## Usage:
1. http://localhost:8000/api/v1/celery-inspect/ping/
{
"worker2@localhost:8000": {
"ok": "pong"
},
"worker1@localhost:8000": {
"ok": "pong"
}
}
2. http://localhost:8000/api/v1/celery-inspect/active/{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}
3. http://localhost:8000/api/v1/celery-inspect/registered/{
"worker2@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
],
"worker1@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
]
}
4. http://localhost:8000/api/v1/celery-inspect/scheduled/{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}### If for some reason you can only deal with status codes (This feature will only work if you have django-celery installed)
1. http://localhost:8000/api/v1/celery-inspect/active-status/
- Returns 200 if all workers in WorkerState are up.
- Returns 404 if workers are down (WorkerState != then inspect()).
- Returns 501 if djcelery a.k.a django-celery is not installed.