Skip to content

mlech-reef/django-business-metrics

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%