{"id":13708477,"url":"https://github.com/django-postgres-metrics/django-postgres-metrics","last_synced_at":"2025-05-06T13:30:43.280Z","repository":{"id":26869661,"uuid":"111322592","full_name":"django-postgres-metrics/django-postgres-metrics","owner":"django-postgres-metrics","description":"A Django application that exposes a bunch of PostgreSQL database metrics.","archived":false,"fork":false,"pushed_at":"2024-08-05T22:07:16.000Z","size":377,"stargazers_count":143,"open_issues_count":8,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-06T03:18:42.978Z","etag":null,"topics":["django","metrics","performance","postgresql"],"latest_commit_sha":null,"homepage":"http://django-postgres-metrics.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/django-postgres-metrics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["MarkusH"]}},"created_at":"2017-11-19T18:50:42.000Z","updated_at":"2024-06-18T17:26:54.000Z","dependencies_parsed_at":"2023-11-13T21:24:38.476Z","dependency_job_id":"4c1c005d-514b-43e4-b963-ef68f49783ca","html_url":"https://github.com/django-postgres-metrics/django-postgres-metrics","commit_stats":{"total_commits":159,"total_committers":6,"mean_commits":26.5,"dds":0.1572327044025157,"last_synced_commit":"2f1f04cd0d5609cd253813d08292ad31d2afaa68"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django-postgres-metrics%2Fdjango-postgres-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django-postgres-metrics%2Fdjango-postgres-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django-postgres-metrics%2Fdjango-postgres-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/django-postgres-metrics%2Fdjango-postgres-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/django-postgres-metrics","download_url":"https://codeload.github.com/django-postgres-metrics/django-postgres-metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224504094,"owners_count":17322333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","metrics","performance","postgresql"],"created_at":"2024-08-02T23:00:23.719Z","updated_at":"2024-11-13T18:31:20.942Z","avatar_url":"https://github.com/django-postgres-metrics.png","language":"Python","funding_links":["https://github.com/sponsors/MarkusH"],"categories":["Monitoring"],"sub_categories":["Tools"],"readme":"# django-postgres-metrics\n\n[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/django-postgres-metrics/django-postgres-metrics/test-deploy.yml?style=for-the-badge)](https://github.com/django-postgres-metrics/django-postgres-metrics/actions/workflows/test-deploy.yml?query=event%3Apush+branch%3Amain)\n[![Codecov coverage](https://img.shields.io/codecov/c/gh/django-postgres-metrics/django-postgres-metrics/main?style=for-the-badge)](https://app.codecov.io/gh/django-postgres-metrics/django-postgres-metrics/branch/main)\n[![Read the Docs](https://img.shields.io/readthedocs/django-postgres-metrics?style=for-the-badge)](https://django-postgres-metrics.readthedocs.io/)\n[![Version](https://img.shields.io/pypi/v/django-postgres-metrics?label=Version\u0026style=for-the-badge)](https://pypi.org/project/django-postgres-metrics/)\n![License: BSD](https://img.shields.io/pypi/l/django-postgres-metrics?style=for-the-badge)\n[![Python Versions: see setup.py](https://img.shields.io/pypi/pyversions/django-postgres-metrics?label=Python\u0026style=for-the-badge)](https://github.com/django-postgres-metrics/django-postgres-metrics/blob/main/setup.py)\n[![Django Versions: see setup.py](https://img.shields.io/pypi/djversions/django-postgres-metrics?color=%230C4B33\u0026label=Django\u0026style=for-the-badge)](https://github.com/django-postgres-metrics/django-postgres-metrics/blob/main/setup.py)\n\nA Django application that exposes a bunch of PostgreSQL database metrics.\n\n## Background\n\nAt [PyCon Canada 2017](https://2017.pycon.ca/) [Craig Kerstiens](http://www.craigkerstiens.com/)\ngave a talk \"[Postgres at any scale](https://2017.pycon.ca/schedule/56/)\". In his talk Craig\npointed out a bunch of metrics one should look at to understand why a PostgreSQL database could\nbe \"slow\" or not perform as expected.\n\nThis project adds a Django Admin view exposing these metrics to Django users with the\n`is_superusers` flag turned on.\n\n## Installation\n\nStart by installing `django-postgres-metrics` from PyPI:\n\n```console\n(env)$ python -m pip install django-postgres-metrics\n```\n\nYou will also need to make sure to have `psycopg2` or `psycopg` installed which\nis already a requirement by Django for PostgreSQL support anyway.\n\nThen you need to add `postgres_metrics` to your `INSTALLED_APPS` list. Due to the way\n`django-postgres-metrics` works, you need to include it \\_before\\* the `admin` app:\n\n```python\nINSTALLED_APPS = [\n    'postgres_metrics.apps.PostgresMetrics',\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n]\n```\n\nYou also need to make sure that the `request` context processor is included in the `TEMPLATES`\nsetting. It is included by default for projects that were started on Django 1.8 or later:\n\n```python\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'OPTIONS': {\n            'context_processors': [\n                ...,\n                'django.template.context_processors.request',\n                ...,\n            ],\n        },\n    },\n]\n```\n\nLastly, you need to add a URL path to your global `urls.py` _before_ the `admin` URL patterns.\n\n```python\nfrom django.urls import include, path\n\nurlpatterns = [\n    path('admin/postgres-metrics/', include('postgres_metrics.urls')),\n    path('admin/', admin.site.urls),\n]\n```\n\nThis is what a metric could look like:\n![Screenshot of the Detailed Index Usage metric, with help text, and a table with rows for each index](https://github.com/django-postgres-metrics/django-postgres-metrics/blob/main/docs/source/_static/screenshot-view.png)\n\n![The same output but using the pgm_show_metric management command](https://github.com/django-postgres-metrics/django-postgres-metrics/blob/main/docs/source/_static/screenshot-cmd-show.svg)\n\n## Security\n\nIf you found or if you think you found a security issue please get in touch via\n`info+django-postgres-metrics *at* markusholtermann *dot* eu`.\n\nI'm working about this in my free time. I don't have time to monitor the email 24/7. But you\nshould normally receive a response within a week. If I haven't got back to you within\n2 weeks, please reach out again.\n\n## Contributing\n\nThe project [black](https://pypi.org/project/black/) and\n[isort](https://pypi.org/project/isort/) for formatting its code.\n[flake8](https://pypi.org/project/flake8/) is used for linting. All these are\ncombined into [pre-commit](https://pre-commit.com/) to run before each commit\nand push. To set it up:\n\n```console\n(env)$ python -m pip install '.[dev,test]'\n(env)$ pre-commit install -t pre-commit -t pre-push --install-hooks\n```\n\nTo run the unit tests:\n\n```console\n(env)$ django-admin test -v 2 --settings=tests.settings\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjango-postgres-metrics%2Fdjango-postgres-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjango-postgres-metrics%2Fdjango-postgres-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjango-postgres-metrics%2Fdjango-postgres-metrics/lists"}