Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting /metrics in a WSGI application with multiple processes per process #423

Open
boatcoder opened this issue Mar 15, 2024 · 1 comment

Comments

@boatcoder
Copy link

I'm not sure how to read multiple processes per process. Is this supposed to be multiple threads per process?

@nezumisama
Copy link

nezumisama commented Aug 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants