--- id: django-prometheus version: "2.5.0" license: Apache license_treatment: permissive maintenance: active --- # django-prometheus — Django middlewares to monitor your application with Prometheus.io. License: permissive · Maintenance: active · Downloads: 4.5M/mo ## 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 above — 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 pip install django-prometheus uv add django-prometheus poetry add django-prometheus ## Installing 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: unspecified - Install friction: low - Maintenance: active - Downloads: 4.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags django prometheus metrics, django monitoring prometheus, prometheus django middleware, django request metrics, django database monitoring, django cache metrics, django, prometheus, observability [View on SkillFed](https://skillfed.io/packages/django-prometheus) · [View on PyPI](https://pypi.org/project/django-prometheus/)