Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonashaag/prometheus-multiprocessing-example
Prometheus Gunicorn multiple worker processes integration example with Flask
https://github.com/jonashaag/prometheus-multiprocessing-example
Last synced: 10 days ago
JSON representation
Prometheus Gunicorn multiple worker processes integration example with Flask
- Host: GitHub
- URL: https://github.com/jonashaag/prometheus-multiprocessing-example
- Owner: jonashaag
- License: isc
- Created: 2016-10-19T09:58:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-17T08:47:47.000Z (10 months ago)
- Last Synced: 2024-10-14T16:58:24.307Z (23 days ago)
- Language: Python
- Size: 4.88 KB
- Stars: 65
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gunicorn multi-worker Prometheus example
**FastAPI**: See https://prometheus.github.io/client_python/exporting/http/fastapi-gunicorn/.
This example web application shows how you can use Prometheus to monitor Flask web
applications that are deployed using multiple Gunicorn works. To be specific,
it explains how you can emit, collect and expose Prometheus metrics from
multiple Gunicorn worker processes.The integration uses a special multi-processing feature in the Prometheus client,
details of which you can find here: https://prometheus.github.io/client_python/multiprocess/## Setup
In a virtualenv, install Flask, Gunicorn and the Python Prometheus client:
pip install flask gunicorn prometheus-client
## Deployment
Metrics emitted by each worker are stored in a shared directory that has to be
specified upfront using the `PROMETHEUS_MULTIPROC_DIR` environment variable.To deploy the example application with 4 Gunicorn worker processes:
rm -rf multiproc-tmp
mkdir multiproc-tmp
export PROMETHEUS_MULTIPROC_DIR=multiproc-tmp
gunicorn -c gunicorn_conf.py -w 4 yourapp:appYou are responsible for ensuring the temporary directory exists and is cleaned
up before each deployment.