Giter Club home page Giter Club logo

django-postgres-metrics's Introduction

django-postgres-metrics

A Django application that exposes a bunch of PostgreSQL database metrics.

Background

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.

Installation

Start by installing django-postgres-metrics from PyPI:

$ pip install django-postgres-metrics

You will also need to make sure to have psycopg2 or psycopg2-binary 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 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.

For Django 2.0 and up:

from django.urls import include, path
urlpatterns = [
    path('admin/postgres-metrics/', include('postgres_metrics.urls')),
    path('admin/', admin.site.urls),
]

For Django 1.11 and before:

from django.conf.urls import include, url
urlpatterns = [
    url(r'^admin/postgres-metrics/', include('postgres_metrics.urls')),
    url(r'^admin/', admin.site.urls),
]

Security

If you found or if you think you found a security issue please get in touch via info+django-postgres-stats *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.

TESTING

To run the unit tests:

$ pip install tox
$ tox

django-postgres-metrics's People

Contributors

funkybob avatar markush avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.