Skip to main content

Django Prometheus business metrics

This Django app provides a Prometheus metrics endpoint serving so-called business metrics. These are metrics that are calculated when Prometheus hits the metrics endpoint.

Usage

This project uses ApiVer. Always import from django_business_metrics.v0 namespace and not from django_business_metrics.

  1. Create a BusinessMetricsManager object and register some metrics:

    # project/business_metrics.py
    
    from django_business_metrics.v0 import BusinessMetricsManager, users
    
    metrics_manager = BusinessMetricsManager()
    
    # Add a pre-defined metric
    metrics_manager.add(users)
    
    # Add some custom metrics
    @metrics_manager.metric(name='name', documentation='documentation')
    def my_metric():
        return 10
    
  2. Register a Prometheus endpoint:

    # project/urls.py
    
    ...
    from .business_metrics import metrics_manager
    
    ...
    urlpatterns = [
        ...
        path('business-metrics', metrics_manager.view),
        ...
    ]
    
  3. Setup your Prometheus agent to scrape metrics from /business-metrics endpoint.

Development

Base requirements

  • docker, docker-compose
  • nox
  • pdm

Handy commands for development

pdm install --dev

Before committing make sure to run:

nox -s format test

Release files for django-business-metrics 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-business-metrics 1.0.1
File Size Uploaded
django_business_metrics-1.0.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-business-metrics 1.0.1
File Interpreter ABI Platform
django_business_metrics-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / django_business_metrics-1.0.1.tar.gz

Download URL django_business_metrics-1.0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b1c63e0d49153503cbc4f03e18af798537e97da9635f8acf7b7232e32bee018a
BLAKE2b-256 checksum
How to use checksums
e7fbeb6a640cc8c37ca82512a3fd813c7cc9ac0b50016ce64206ce4de91e95f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.9.3 CPython/3.12.0

Release files / django_business_metrics-1.0.1-py3-none-any.whl

Download URL django_business_metrics-1.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08df7c71d81652adf399865a3ad5f62d81d16551217b297efe90e3a1b88e4394
BLAKE2b-256 checksum
How to use checksums
4898e3747035baeea0c05192bab4dc47cb3e1d2eb14210260469e52f4cc48eef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.9.3 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page