我在RabbitMQ 3.4.1后端上运行Celery 3.1.16,并在Python3.4上使用Flower 0.7.3监视我的 celery 任务。我有几个正在运行的任务,可以在Celery Flower的任务选项卡中查看其结果。

monitor标签中,有4个部分。成功的任务,失败的任务,任务时间和代理。在这4个中,只有Broker View 显示了“流量”图。是否有设置使其他图形显示一些统计信息?

flowerconfig.py

# Broker settings
BROKER_URL = 'amqp://guest:guest@localhost:5672//'

# RabbitMQ management api
broker_api = 'http://guest:guest@localhost:15672/api/'

#Port
port = 5555

# Enable debug logging
logging = 'INFO'

主管:flower.conf
[program:flower]
command=/opt/apps/venv/my_app/bin/celery flower --app=celery_conf.celeryapp --conf=flowerconfig
directory=/opt/apps/my_app/celery_conf
user=www-data
autostart=true
autorestart=true
startsecs=10
redirect_stderr=true
stderr_logfile=/var/log/celery/flower.err.log
stdout_logfile=/var/log/celery/flower.out.log

进行此操作时,在“代理”图中,我有两个队列,一个是绿色,另一个是红色。但是,图中显示的是红色,但两者都正在运行,我可以从“任务”窗口中查看其结果。

我注意到Flower中 worker 选项卡下的 Config选项卡中有一些特殊的地方。 CELERY_ROUTE和CELERY_QUEUES显示为空列表,而所有其他字段似乎都从celeryconfig文件中选择了正确的数据
BROKER_URL  amqp://guest:********@localhost:5672//
CELERYBEAT_SCHEDULE {}
CELERYD_PREFETCH_MULTIPLIER 0
CELERY_ALWAYS_EAGER False
CELERY_AMQP_TASK_RESULT_EXPIRES 60
CELERY_CREATE_MISSING_QUEUES    False
CELERY_DEFAULT_EXCHANGE default
CELERY_DEFAULT_QUEUE    default
CELERY_DEFAULT_ROUTING_KEY  ********
CELERY_IMPORTS  ['student.admission', 'student.schedule']
CELERY_INCLUDE  ['celery.app.builtins', 'student.schedule', 'student.admission']
CELERY_QUEUES   [{}, {}, {}, {}, {}]     #<==== Should it show an empty list?
CELERY_RESULT_BACKEND   amqp://guest:guest@localhost:5672//
CELERY_ROUTES   [{}, {}, {}, {}]     #<==== Should it show an empty list?
CELERY_STORE_ERRORS_EVEN_IF_IGNORED True
CELERY_TASK_RESULT_EXPIRES  3600

celeryconfig.py 如下所示:
BROKER_URL = 'amqp://guest:guest@localhost:5672//'
CELERY_RESULT_BACKEND = 'amqp://guest:guest@localhost:5672//'

#Task settings
CELERY_TASK_RESULT_EXPIRES = 3600
CELERY_AMQP_TASK_RESULT_EXPIRES = 60
CELERYD_PREFETCH_MULTIPLIER = 0
CELERY_ALWAYS_EAGER = False
CELERY_CREATE_MISSING_QUEUES = False
CELERY_STORE_ERRORS_EVEN_IF_IGNORED = True

#Scripts to be imported
CELERY_IMPORTS=('student.admission', 'student.schedule')

#Celery Exchanges, Queues, Routes
default_exchange = Exchange('default', type='direct')
student_admission_exchange = Exchange('student_admission_exchange', type='direct', durable=False)

CELERY_QUEUES = (
    Queue('default', default_exchange, routing_key='default'),
    Queue('student_admission_queue', student_admission_exchange, routing_key='admission', durable=False),
)
CELERY_ROUTES = (
                 {'student.admission.admit': {'queue': 'student_admission_queue','routing_key': 'admission'}},
                     )
CELERY_DEFAULT_QUEUE = 'default'
CELERY_DEFAULT_EXCHANGE = 'default'
CELERY_DEFAULT_ROUTING_KEY = 'default'

编辑

虽然我并不是唯一一个坚持这一观点的人,但我还是将“缺失”图的屏幕截图作为指南。

最佳答案

就我而言,这不是Flower本身的问题,而是我的任务上的时间戳记不准确的事实(如我的 celery 日志中的消息“从***大量漂移可能表示时钟不同步”所显示的那样) )。固定时钟可能是答案。

Flower通过将事件的时间戳与上次更新该图的时间戳进行比较(请参阅https://github.com/mher/flower/blob/master/flower/views/monitor.py#L47),从而确定事件是否是新事件(因此需要绘制)。在我的情况下,该比较始终为False,因此未绘制任何事件。

关于python - 如何在 celery 花监控器选项卡中查看所有图形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27033338/

10-12 20:43