
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
django-postgres-metrics
Advanced tools
A Django application that exposes a bunch of PostgreSQL database metrics.
At PyCon Canada 2017 Craig Kerstiens gave a talk "Postgres at any scale". In his talk Craig pointed out a bunch of metrics one should look at to understand why a PostgreSQL database could be "slow" or not perform as expected.
This project adds a Django Admin view exposing these metrics to Django users with the
is_superusers
flag turned on.
Start by installing django-postgres-metrics
from PyPI:
(env)$ python -m pip install django-postgres-metrics
You will also need to make sure to have psycopg2
or psycopg
installed which
is already a requirement by Django for PostgreSQL support anyway.
Then you need to add postgres_metrics
to your INSTALLED_APPS
list. Due to the way
django-postgres-metrics
works, you need to include it _before* the admin
app:
INSTALLED_APPS = [
'postgres_metrics.apps.PostgresMetrics',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
You also need to make sure that the request
context processor is included in the TEMPLATES
setting. It is included by default for projects that were started on Django 1.8 or later:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
...,
'django.template.context_processors.request',
...,
],
},
},
]
Lastly, you need to add a URL path to your global urls.py
before the admin
URL patterns.
from django.urls import include, path
urlpatterns = [
path('admin/postgres-metrics/', include('postgres_metrics.urls')),
path('admin/', admin.site.urls),
]
This is what a metric could look like:
If you found or if you think you found a security issue please get in touch via
info+django-postgres-metrics *at* markusholtermann *dot* eu
.
I'm working about this in my free time. I don't have time to monitor the email 24/7. But you should normally receive a response within a week. If I haven't got back to you within 2 weeks, please reach out again.
The project black and isort for formatting its code. flake8 is used for linting. All these are combined into pre-commit to run before each commit and push. To set it up:
(env)$ python -m pip install '.[dev,test]'
(env)$ pre-commit install -t pre-commit -t pre-push --install-hooks
To run the unit tests:
(env)$ django-admin test -v 2 --settings=tests.settings
FAQs
A Django app that exposes a bunch of PostgreSQL database metrics.
We found that django-postgres-metrics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.