Route-aware analytics dashboard for Django: discover your URLs and DRF APIs, and see traffic, performance, and audience metrics for each of them.
Project description
django-prometric
Route-aware analytics and operational insight for Django.
django-prometric discovers the URLs and Django REST Framework endpoints in your project, then connects traffic, performance, audience, error, and database metrics to the routes that produced them—all inside a protected Django dashboard.
Quick start · Providers · Configuration · Security · Development
Beta: Test the dashboard in a non-critical environment before rolling it out broadly.
Why django-prometric?
| Capability | What it gives you |
|---|---|
| Route discovery | Django and DRF endpoints without manual registration |
| Unified analytics | Edge, application, and database metrics in one dashboard |
| Per-route insight | Traffic and performance connected to the relevant URL pattern |
| Provider composition | Cloudflare, Sentry, PostgreSQL, and custom providers in priority order |
| Historical comparison | Snapshots and repeated runs compared over time |
| Private by default | Django authentication, permissions, and superuser-only default access |
| No frontend toolchain | Packaged templates, CSS, and JavaScript ready for collectstatic |
Providers
| Provider | Contributes | Install | Setup |
|---|---|---|---|
| Cloudflare | Traffic, audience, cache, bandwidth, bots, security, SEO, and network data | django-prometric[cloudflare] |
API token + zone ID |
| Sentry | Application performance, slow routes, issues, queries, and backend operations | django-prometric[sentry] |
Auth token + organization |
| PostgreSQL | Database health, tables, indexes, slow queries, and derived insights | django-prometric[postgres] |
Existing Django PostgreSQL connection |
Providers are evaluated in list order. The first configured provider capable of supplying a dashboard component is used for that component. Unconfigured providers stay visible with setup instructions instead of breaking the dashboard.
Compatibility
| Supported versions | |
|---|---|
| Python | 3.9–3.14 |
| Django | 4.2, 5.0, 5.1, 5.2, 6.0 |
The only required runtime dependency is Django 4.2 or newer. DRF integration activates automatically when Django REST Framework is installed.
Quick start
1. Install
Install the core package with the extras for the providers you plan to use:
python -m pip install "django-prometric[full]"
| Command | What it installs |
|---|---|
pip install django-prometric |
Core dashboard; Cloudflare and Sentry already work (standard library only) |
pip install "django-prometric[postgres]" |
Core + the psycopg driver for the PostgreSQL provider |
pip install "django-prometric[full]" |
Core + every provider dependency |
[cloudflare] and [sentry] are currently empty extras — they exist so the
per-provider install commands stay stable if those providers ever need a
dependency of their own.
2. Register the application
INSTALLED_APPS = [
# ...
"django_prometric",
]
3. Mount the dashboard
from django.urls import include, path
urlpatterns = [
# ...
path("prometric/", include("django_prometric.urls")),
]
4. Apply migrations
python manage.py migrate
5. Open the dashboard
Sign in as a superuser and visit /prometric/. Providers without credentials
will show their setup requirements on the Providers page.
For production deployments, include django-prometric in your normal static files workflow:
python manage.py collectstatic
Provider setup
Enable providers in the order you want them considered:
DJANGO_PROMETRIC = {
"PROVIDERS": ["cloudflare", "sentry", "postgres"],
}
Cloudflare and Sentry are listed by default. PostgreSQL is opt-in.
Cloudflare
Create an API token with Analytics Read permission, then expose the token and zone ID to the Django process:
export CLOUDFLARE_API_TOKEN="..."
export CLOUDFLARE_ZONE_ID="..."
If one zone serves several applications, limit analytics to this project's hostnames:
DJANGO_PROMETRIC = {
"PROVIDERS": ["cloudflare"],
"CLOUDFLARE": {
"HOSTS": ["example.com", "www.example.com"],
},
}
Some route-level and performance metrics depend on the Cloudflare plan. The provider detects unavailable features and reports plan limits in the UI.
Sentry
Create an auth token with org:read and event:read scopes:
export SENTRY_API_TOKEN="..."
export SENTRY_ORG="your-organization-slug"
export SENTRY_PROJECT="your-project-slug" # optional
When SENTRY_PROJECT is omitted, the first project returned by Sentry is used.
The default performance lookback is 14 days; change it with
DJANGO_PROMETRIC["SENTRY"]["MAX_DAYS"].
PostgreSQL
Install the provider's driver, then point it at a database:
python -m pip install "django-prometric[postgres]"
If your Django project already talks to PostgreSQL, the driver is already installed and the extra adds nothing new. The provider reads the selected Django database connection and requires no external API or token:
DJANGO_PROMETRIC = {
"PROVIDERS": ["postgres"],
"POSTGRES": {
"DB_ALIAS": "default",
},
}
Database, table, and index metrics use standard PostgreSQL statistics views.
Query-level metrics additionally require pg_stat_statements.
Read the PostgreSQL provider guide for extension setup, permissions, and metric semantics.
Custom providers
Any data source can feed the dashboard. Subclass AnalyticsProvider, declare
the capabilities you can answer, and implement the matching get_* methods:
from django_prometric.providers import base
from django_prometric.providers.base import AnalyticsProvider, OverviewStats
class MyProvider(AnalyticsProvider):
slug = "mysource"
verbose_name = "My source"
def capabilities(self):
return {base.OVERVIEW}
def get_overview(self, period):
return OverviewStats(requests=...)
List it by dotted path, mixed freely with the built-in aliases:
DJANGO_PROMETRIC = {
"PROVIDERS": ["cloudflare", "myproject.analytics.MyProvider"],
}
The full contract — capabilities, time windows, and the result dataclasses —
lives in django_prometric.providers.base.
Configuration
All settings are optional and live under one DJANGO_PROMETRIC dictionary:
DJANGO_PROMETRIC = {
"PROVIDERS": ["cloudflare", "sentry"],
"ACCESS": "superuser",
"STEALTH_404": False,
"CACHE_ALIAS": "default",
"CACHE_TTL": 300,
"SITE_NAME": None,
}
Built-in provider aliases may be mixed with dotted paths to custom
AnalyticsProvider subclasses.
Route filtering
Administrative routes are excluded by default. Additional routes can be selected with regular expressions matched against their display paths:
DJANGO_PROMETRIC = {
"ROUTES": {
"MODE": "exclude", # all | include | exclude
"EXCLUDE": [r"^/health/$", r"^/internal/"],
"EXCLUDE_ADMIN": True,
},
}
For application-specific rules, set ROUTES.FILTER to a dotted callable. It
receives a display path and returns True when the route should be kept.
Security
The dashboard exposes operational information. Do not make it anonymously accessible.
Access is restricted to superusers by default:
DJANGO_PROMETRIC = {
"ACCESS": "superuser", # superuser | staff | permission | dotted callable
"STEALTH_404": True,
}
Users granted django_prometric.view_dashboard can access the dashboard
regardless of the baseline policy. Set ACCESS to permission to allow only
explicitly granted users and groups.
A custom policy must accept the current user and return a boolean:
DJANGO_PROMETRIC = {
"ACCESS": "myproject.permissions.can_view_metrics",
}
With STEALTH_404 enabled, unauthorized requests receive a 404 response
instead of a login redirect or permission error.
Development
git clone https://github.com/mohsensalare/DjangoProMetric.git
cd DjangoProMetric
python -m pip install -e ".[dev]"
python -m pytest
ruff check .
ruff format --check .
These are the same checks CI runs on every push and pull request. The build and release process — versioning, tags, and Trusted Publishing to PyPI — is documented in RELEASING.md.
Links
License
django-prometric is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_prometric-0.2.1.tar.gz.
File metadata
- Download URL: django_prometric-0.2.1.tar.gz
- Upload date:
- Size: 183.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af0c32a1a5fabcba9d4ea147178ddb1902f9c74d9b1f83e50986251d4c0f2219
|
|
| MD5 |
28b9e0ceb05e14e3750fcdd6fbec6f63
|
|
| BLAKE2b-256 |
3e6c1f01873fa53ce45bc5abdb89b06c0a43483e03a5eb24aad4883a17cf6080
|
Provenance
The following attestation bundles were made for django_prometric-0.2.1.tar.gz:
Publisher:
release.yml on mohsensalare/DjangoProMetric
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_prometric-0.2.1.tar.gz -
Subject digest:
af0c32a1a5fabcba9d4ea147178ddb1902f9c74d9b1f83e50986251d4c0f2219 - Sigstore transparency entry: 2087109182
- Sigstore integration time:
-
Permalink:
mohsensalare/DjangoProMetric@5b346b9f73953a9431562dabc0378ddc916a9d99 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mohsensalare
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b346b9f73953a9431562dabc0378ddc916a9d99 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_prometric-0.2.1-py3-none-any.whl.
File metadata
- Download URL: django_prometric-0.2.1-py3-none-any.whl
- Upload date:
- Size: 210.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc7954c6d7eb4b88ce17ad87dfd615d3ae4aa6b6c7e1bc4edc631a57859e712a
|
|
| MD5 |
9a4aaa03b7ba3bb5e7b404dba0a93553
|
|
| BLAKE2b-256 |
aaa6475a12135d83ae113da8c01bd9c4c4c23250cf9f035a05800c8fe8754727
|
Provenance
The following attestation bundles were made for django_prometric-0.2.1-py3-none-any.whl:
Publisher:
release.yml on mohsensalare/DjangoProMetric
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_prometric-0.2.1-py3-none-any.whl -
Subject digest:
cc7954c6d7eb4b88ce17ad87dfd615d3ae4aa6b6c7e1bc4edc631a57859e712a - Sigstore transparency entry: 2087109610
- Sigstore integration time:
-
Permalink:
mohsensalare/DjangoProMetric@5b346b9f73953a9431562dabc0378ddc916a9d99 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mohsensalare
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5b346b9f73953a9431562dabc0378ddc916a9d99 -
Trigger Event:
push
-
Statement type: