OvalMoney / celery-exporter

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

Queue name in the Prometheus metrics #9

Closed mdawar closed 4 years ago

mdawar commented 5 years ago

Hi, thank you for this project, I have a question please about the exposed metrics.

I'm trying the exporter locally, without any tasks I can check the celery_tasks_total metric in the Prometheus dashboard and I can see my tasks:

celery_tasks_total{instance="celery_exporter:9540",job="celery_exporter",name="info",namespace="celery",queue="default",state="STARTED"}

The queue as you can see is default, for this task the value is right because I have changed my default task name from celery to default, but the problem is that all the other tasks also have the queue as default even thought each task has a queue with the same name:

celery_tasks_total{instance="celery_exporter:9540",job="celery_exporter",name="process",namespace="celery",queue="default",state="STARTED"}

As you can see, here the queue should be process for my task process but it's default, that's also the case for other tasks.

Also when I delay new tasks to be processed, these metrics stay the same with their values of 0 and new metrics show up for every task but this time with the queue value of undefined with the correct number of tasks:

celery_tasks_total{instance="celery_exporter:9540",job="celery_exporter",name="info",namespace="celery",queue="undefined",state="STARTED"}

So what could be wrong here? I have my queues defined as the task_queues Celery option, and for all the tasks except the default one I'm setting the queue argument of the @app.task() decorator.

MRoci commented 5 years ago

Have you configured workers with task_send_sent_event option ( http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-send-sent-event )or are you launching the exporter with --enable-events flag? This seems like the exporter is not capturing events containing queue infos

mdawar commented 5 years ago

@MRoci I'm not using --enable-events but I have task_send_sent_event and worker_send_task_events set to True on the workers, I have tested this configuration again and got the same results, the queue is default for tasks that don't use the default queue and sometimes undefined.

SharpEdgeMarshall commented 5 years ago

Are you able to add a test reproducing the issue in a PR so we could take a look at it?

mdawar commented 5 years ago

@SharpEdgeMarshall Yes I will when I get some free time.

orkenstein commented 4 years ago

So, looks like this never happened. @mdawar were you able to fix that? I've experienced the same #21

mdawar commented 4 years ago

@orkenstein sorry I haven't had the time to find a fix and I no longer use this exporter because I moved to RQ from Celery.