Hi all!

I have:

1. django app run with
python manage.py runserver

2. celery worker run with 
celery -A project worker -l info

3. celery beat run with

celery -A project beat -l info


They will be deployed in their own pods in kubernetes.


*/metrics* endpoint is exposed in Django app but metrics are being gathered in 
Celery tasks. 

And because these two apps and run in two different process (pods) they have 
two different registries.

That's why from Django I can't get metrics from registry in Celery process.


If there is any way to handle this? It seems that 
prometheus_client.multiprocess.MultiProcessCollector can help.

I tried this but it didn't work:


*settings.**py*

registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry, path=
'/home/aleksandrovalbert/Work/blackbox_exporter/exporter/multiproc-tmp')



*views.*
*py*

from project.settings import registry


def export(request):
    metrics_page = prometheus_client.generate_latest(registry)
    return HttpResponse(metrics_page, content_type=prometheus_client.
CONTENT_TYPE_LATEST)


*tasks.**py*

registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry, path=
'/home/aleksandrovalbert/Work/blackbox_exporter/exporter/multiproc-tmp')


class TestBeatPeriodicTask(PeriodicTask):
    run_every = timedelta(minutes=1)

    metric = Gauge(
       name='test_beat',
       documentation='Работоспособность процесса обработки загрузки.',
       registry=registry
    )

    def run(self):
        metric.set(888)

Or this can be handled with pushgateway only?

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/a4e277a3-a8cd-4eb9-af46-cd881f2766cc%40googlegroups.com.

Reply via email to