Skip to main content

Django Prometheus business metrics

Reason this release was yanked:

It's a broken version, models.py file shouldn't be there

Project description

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

poetry install

Before committing make sure to run:

nox -s format test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-business-metrics-1.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

django_business_metrics-1.0.0-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page