Prometheus + Django + gunicorn with --preload and multiple processes publishing just one port

Viewed 878

I'm running django+prometheus+gunicorn, exporting /metrics using multiple processes per process, as described in django-prometheus documentation. When I run gunicorn with --reload and two workers, I can see how ports 8001 and 8002 are opened serving prometheus metrics, one per process. But when I run gunicorn with --preload, only port 8001 is opened.

What do I need to do to get one prometheus endpoint per process while using --preload?

django-prometheus settings:

PROMETHEUS_METRICS_EXPORT_PORT_RANGE = range(8001, 8020)
PROMETHEUS_METRICS_EXPORT_ADDRESS = ''
PROMETHEUS_EXPORT_MIGRATIONS = False

Versions:

django==3.1.0
prometheus_client==0.8.0
django-prometheus==2.1.0
gunicorn==20.0.4
0 Answers
Related