Prometheus is a great metrics monitoring system and works particularly well with Go where a web application is usually a single process behind nginx.

With Python and gunicorn it gets quite complicated as there are several instances of the same web app. If you use gunicorn and follow the default instructions on integrating the Python client for Prometheus you will end up with useless metrics as gunicorn will load balance the /metrics endpoint between each gunicorn worker.

(Clone this repo if you want to try these examples)

Let’s see how this works with a simple Flask app and Prometheus listening on a separate port.