OvalMoney / celery-exporter

Prometheus metrics exporter for Celery
MIT License
142 stars 37 forks source link

Task's queue is 'undefined' #21

Open orkenstein opened 4 years ago

orkenstein commented 4 years ago

By some reason the output is the following:

celery_tasks_total{name="local.update_record",namespace="celery",queue="local_develop",state="STARTED"} 0.0
# skipped
celery_tasks_total{name="local.update_record",namespace="celery",queue="undefined",state="STARTED"} 1.0

All recorded tasks have queue as "undefined".

itsx commented 4 years ago

We have the same problem:

celery_tasks_total{name="watcher.process_notifications",namespace="celery",queue="celery",state="RECEIVED"} 0.0
# skipped
celery_tasks_total{name="watcher.process_notifications",namespace="celery",queue="undefined",state="RECEIVED"} 1012.0

queue="celery" is wrong, we don't have celery queue with such a name. Same with the queue="undefined".

I checked how our Celery task events look like and it seems, that they are ok and contain all expected data.

Example of out task-received event:

{
   "hostname":"worker-watcher@xyz.com",
   "utcoffset":0,
   "pid":1,
   "clock":137700979,
   "uuid":"fc8bb20f-4e1d-48ac-9f35-bbc0f7724143",
   "name":"watcher.process_notifications",
   "args":"()",
   "kwargs":"{'notify_period': 'immediately'}",
   "root_id":"fc8bb20f-4e1d-48ac-9f35-bbc0f7724143",
   "parent_id":"None",
   "retries":0,
   "eta":"None",
   "expires":"2020-06-17T11:55:42.823008+00:00",
   "timestamp":1592387682.8286304,
   "type":"task-received",
   "local_received":1592394882.9463646
}

I have also noticed that I have not received any task-sent events, I run the exporter with --enable-events flag.

SharpEdgeMarshall commented 4 years ago

We are aware of this bug it's not easy to refresh the queue list in real time. @itsx the "celery" queue is the default one is used to run internal celery tasks

johnnymetz commented 3 years ago

Having the same issue:

celery_tasks_total{name="core.tasks.square",namespace="celery",queue="celery",state="SUCCESS"} 0.0
celery_tasks_total{name="core.tasks.square",namespace="celery",queue="undefined",state="SUCCESS"} 4.0
luvwinnie commented 3 years ago

having the same issue, does anyone know how to fix this?

luvwinnie commented 3 years ago

I have try added the following settings.

celery.conf.task_queues=(
    Queue('task1_queue'),
    Queue('task2_queue')
)

# with of without routing_key just the same
celery.conf.task_routes={
        'task1': {'queue': 'task1_queue'},#,'routing_key':'task1'},
        'task2': {'queue': 'task2_queue'}#,'routing_key':'task2'}
}

and send the task with following command however it seems like the metrics created the queue with name=undefined.

celery_app.send_task(
                "task1", args=[], kwargs={"payload": jsonable_encoder(data),},time_limit=CELERYD_TASK_TIME_LIMIT,compression="gzip",queue="task1_queue"
        )
gergelypolonkai commented 2 years ago

Same here; all queues except celery are named undefined in the metrics output. I run the workers with --task-events and despite that i start the exporter with --enable-events.