I am building a framework for executing tasks on top of Celery framework.
I would like to see the list of recently executed tasks (for the recent 2-7 days).
Looking on the API I can find app.backend
object, but cannot figure out how to make a query to fetch tasks.
For example I can use backends like Redis or database. I do not want to explicitly write SQL queries to database.
Is there a way to work with task history/results with API?
I tried to use Flower, but it can only handle events and cannot get history before its start.
Celery have specific option -f --logfile which you can use: -f LOGFILE, --logfile=LOGFILE Path to log file.
Just to spell things out, the DATABASE_NUMBER used by default is 0 , and the QUEUE_NAME is celery , so redis-cli -n 0 llen celery will return the number of queued messages.
You can use the persisent option,eg: flower -A ctq.celery --persistent=True
You need to keep the task results in a backend, for example Redis. The Celery documentation contains information about how to do this here:
http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results
Also you want to set the CELERY_TASK_RESULT_EXPIRES configuration parameter, because by default the results are discarded after one day.
If you do this, then Flower will show you the history of the task execution, regardless from when it started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With