V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Alexf4
V2EX  ›  Python

celery 如何通过 task_id 查询任务的执行日志

  •  
  •   Alexf4 ·
    alexcc4 · 2021-04-02 11:41:18 +08:00 · 1431 次点击
    这是一个创建于 1113 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近在使用 celery 做任务队列,用 flower 已经可以满足查看某个任务的执行状态,参数,时间等等。

    后面想着定制需求:通过一个 task_id 实时查看执行的情况(类似任务执行里面的 print, logger 等),各位大佬们有没有建议?

    目前自己的大概的想法:

    • 在每个 worker 的执行日志里面操作,做近实时的收集( collectd, fluentd, filebeat 等),然后根据 task_id 在日志的仓库( clickhouse, es )做查询。这个日志搜索会有一定的延迟性
    • 每个 task 配置一个单独的日志文件, 然后在进行查询时候, 利用 websocket 连接服务器(此时服务器找到对应的文件, tail -f )。
    2 条回复    2021-04-02 15:52:01 +08:00
    strict
        1
    strict  
       2021-04-02 15:43:23 +08:00
    简单粗暴,把日志关键数据塞到 result backend 中.
    Alexf4
        2
    Alexf4  
    OP
       2021-04-02 15:52:01 +08:00
    @strict 这个只是保存任务的一些必要参数吧。执行结果,参数,执行时间等等。
    但是像执行日志,类似任务 stdout 输出, 不会在这里面吧?还是有啥盲点我没发现的吗,华生
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5359 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:56 · PVG 16:56 · LAX 01:56 · JFK 04:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.