django-prometheus
Django middlewares to monitor your application with Prometheus.io.
What it is and what it does
django-prometheus is a Django middleware and instrumentation library that automatically collects and exports application metrics in Prometheus format. It hooks into Django's request/response cycle, ORM database operations, cache framework, and model lifecycle to generate counters, histograms, and gauges that Prometheus can scrape. You install it as a Django app, add two middleware classes to your stack, and expose a /metrics endpoint; the library then begins collecting latency, request counts, database query metrics, cache hit/miss rates, and model operation counts without requiring changes to your application code.
The package works with SQLite, MySQL, and PostgreSQL databases, supports filebased, memcached, and redis caches, and allows custom metric labels and namespacing. It integrates directly with prometheus-client and lets you add application-level metrics alongside the built-in Django instrumentation. Configuration is minimal—you can customize latency histogram buckets and metric prefixes in settings—making it suitable for both greenfield and legacy Django projects that need observability without heavy refactoring.
Use it for:
- Monitor HTTP request latency and throughput across your Django application endpoints in real time.
- Track database query performance and frequency to identify slow ORM operations and N+1 problems.
- Alert on cache hit/miss rates and eviction patterns to optimize caching strategy.
- Export model creation, update, and deletion rates to detect anomalous data mutation patterns.
- Collect migration status metrics to ensure all pending database migrations are applied.
- Add custom application-level metrics alongside Django internals using prometheus-client directly.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Exports Django application metrics (requests, database queries, cache operations, model changes) to Prometheus for monitoring and alerting.
Yes. django-prometheus is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It provides production-grade Prometheus instrumentation for Django with minimal setup—add middleware and a URL include, then scrape /metrics. Suitable for any Django project that needs observability without custom instrumentation code.
Install
django-prometheus on PyPI
pip
pip install django-prometheusuv
uv add django-prometheuspoetry
poetry add django-prometheusInstalling django-prometheus
Before you install
Low friction install with just two runtime dependencies (Django and prometheus-client). Package is actively maintained with a recent release and no known vulnerabilities.
License in practice
Apache License (permissive) — you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install django-prometheus
# In settings.py
INSTALLED_APPS = ['django_prometheus', ...]
MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
# ... other middleware ...
'django_prometheus.middleware.PrometheusAfterMiddleware',
]
# In urls.py
urlpatterns = [path('', include('django_prometheus.urls')), ...]
Requires Django >= 4.2 and Python 3.9 or above.
Package facts
| License | Apache (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, prometheus-client |
| Maintenance | actively maintained — 80 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,542,374/month — #2,285 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_prometheus-2.5.0-py2.py3-none-any.whl
Keywords: django, monitoring, prometheus
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
prometheus-clientInstruments Python applications to expose…
permissive · top 1,000 on PyPI
opentelemetry-exporter-prometheusExports OpenTelemetry metrics to Prometheus for…
permissive · top 1,000 on PyPI
prometheus-flask-exporterExports HTTP request metrics from Flask…
permissive · top 5,000 on PyPI
py-grpc-prometheusAdds Prometheus metrics collection to gRPC…
unclear · top 5,000 on PyPI
starlette-exporterCollects and exports Prometheus metrics for…
permissive · top 5,000 on PyPI
prometheus-asyncAdds async/await support to Prometheus metrics…
permissive · top 15,000 on PyPI
opentelemetry-exporter-prometheus-remote-writeExports metrics from OpenTelemetry Python SDK…
permissive · top 5,000 on PyPI
prometheus-client-python-speedupsProvides optional C/Rust-compiled speedups for…
unclear · top 15,000 on PyPI
django-health-checkProvides pluggable health check endpoints for…
permissive · top 5,000 on PyPI
prometheus-remote-writerSends time-series metrics to…
permissive · top 15,000 on PyPI