skillfed

django-prometheus

Django middlewares to monitor your application with Prometheus.io.

django-prometheus v2.5.0 4.5M downloads/30d#2,285 on PyPI1,662
Permissive license Apache Active released

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-prometheus

uv

uv add django-prometheus

poetry

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 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

Development Status :: 5 - Production/StableFramework :: Django :: 4.2Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Free ThreadingTopic :: System :: Monitoring

Tags

django prometheus metricsdjango monitoring prometheusprometheus django middlewaredjango request metricsdjango database monitoringdjango cache metrics
djangoprometheusobservability

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

prometheus-client

Instruments Python applications to expose…

permissive · top 1,000 on PyPI

opentelemetry-exporter-prometheus

Exports OpenTelemetry metrics to Prometheus for…

permissive · top 1,000 on PyPI

prometheus-flask-exporter

Exports HTTP request metrics from Flask…

permissive · top 5,000 on PyPI

py-grpc-prometheus

Adds Prometheus metrics collection to gRPC…

unclear · top 5,000 on PyPI

starlette-exporter

Collects and exports Prometheus metrics for…

permissive · top 5,000 on PyPI

prometheus-async

Adds async/await support to Prometheus metrics…

permissive · top 15,000 on PyPI

opentelemetry-exporter-prometheus-remote-write

Exports metrics from OpenTelemetry Python SDK…

permissive · top 5,000 on PyPI

prometheus-client-python-speedups

Provides optional C/Rust-compiled speedups for…

unclear · top 15,000 on PyPI

django-health-check

Provides pluggable health check endpoints for…

permissive · top 5,000 on PyPI

prometheus-remote-writer

Sends time-series metrics to…

permissive · top 15,000 on PyPI