danihodovic / celery-exporter

A Prometheus exporter for Celery metrics
MIT License
384 stars 85 forks source link

Allow queue cache to be initialized from the command line #260

Closed xulaus closed 11 months ago

xulaus commented 1 year ago

Motivation

We are running celery-exporter in a kubernetes environment and using the metrics it provides to scale the number of workers. Sometimes we scale the number of workers down to zero automatically e.g test environments out of office hours for instance.

When there are no workers, if celery-exporter stops for any reason (e.g. kubernetes moves it to a different node), celery-exporter stops reporting metrics for the queues as it has no way of knowing what the queues are. In our case this means we can never automatically scale back up as the metrics are missing.

As we know all of the queues we wish to be following in advance, being able to tell celery-exporter all the queues we wish to have metrics for is a useful feature.

Implementation

Implementation is straight forward as there is already the queue_cache to deal with the case that workers go away while celery-exporter is running, so all we need to do is prefill that cache.

I've chosen to use -Q and --queues as the command line arguments to match the celery command line.

danihodovic commented 1 year ago

@adinhodovic You run celery-exporter on an autoscaling cluster. What are your thoughts on this?

danihodovic commented 11 months ago

Hi Richard.

Sorry about the delay with reviewing. I have been on holiday.

I've released this as danihodovic/celery-exporter:0.9.2. Thank you.