Exporting /metrics in a WSGI application with multiple processes per process
Opened this issue · 1 comments
boatcoder commented
I'm not sure how to read multiple processes per process. Is this supposed to be multiple threads per process?
nezumisama commented
Hi. I had the same issue. I solved it by adding code to gunicorn config file:
from prometheus_client import CollectorRegistry, multiprocess
def when_ready(_):
multiprocess.MultiProcessCollector(CollectorRegistry())
def child_exit(_, worker):
multiprocess.mark_process_dead(worker.pid)Additionally, an environment variable PROMETHEUS_MULTIPROC_DIR has to be set to some empty dir. This is used to synchronize between workers.