我正在运行带有 RabbitMQ 3.4.1 后端的 Celery 3.1.16,并在 Python3.4 上使用 Flower 0.7.3 来监控我的 celery 任务。我有几个任务正在运行,我可以在 Celery Flower 的任务选项卡中查看它们的结果。
在monitor
选项卡中,有 4 个部分。成功的任务、失败的任务、任务时间和代理。在这 4 个中,只有 Broker 视图显示“流量”图表。是否有启用其他图表显示一些统计信息的设置?
花配置文件
# 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 中Workers 选项卡下的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'
编辑
正如我所看到的,并不是唯一一个坚持这一点的人,尽管我将“缺失”图表的屏幕截图作为指南。