Quickstart django-prometheus setup
masterTo enable basic monitoring of requests and responses, follow these three steps:
- Add
'django_prometheus'to yourINSTALLED_APPS. - Add
PrometheusBeforeMiddlewareto the beginning of yourMIDDLEWARElist andPrometheusAfterMiddlewareto the end of yourMIDDLEWARElist. - Include
django_prometheus.urlsin your project'surlpatternsto expose the/metricsendpoint.
# settings.py
INSTALLED_APPS = [
...
'django_prometheus',
...
]
MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
# All your other middlewares go here...
'django_prometheus.middleware.PrometheusAfterMiddleware',
]
# urls.py
urlpatterns = [
...
path('', include('django_prometheus.urls')),
]