A collection of django middleware to track django + WSGI service metrics accurately via prom/statsd-exporter sidecar + prometheus
Project description
django-statsd-prom-exporter
A collection of django middleware to track django + WSGI service metrics accurately via prom/statsd-exporter sidecar + prometheus
Features
- StatsdCountMetricMiddleware - Request Count & Request Exception Count metrics
- StatsdLatencyMetricMiddleware - Request Latency metrics
- StatsdLogger - Log a custom count metric
Installation
pip install -U django-statsd-prom-exporter
Configuration
To configure django-statsd, you need to add below configuration to django settings
# settings.py
STATSD_HOST = '127.0.0.1' # required
STATSD_PORT = 8045 # required
STATSD_SERVICE_NAME = 'service_name' # optional - adds a dimension to all your metrics
STATSD_PREFIX = '' # optional - adds prefix to all metrics
STATSD_IGNORED_IPS = ['127.0.0.1'] # optional - ignore metrics from requests from listed ips
STATSD_REQUEST_META_IP_PRECEDENCE_ORDER = ('HTTP_X_ORIGINAL_FORWARDED_FOR', 'REMOTE_ADDR') # optional - default request meta precedence order for ip address
Usage
Middleware
Add the following to your settings.py
- Add
django_statsd.middleware.StatsdCountMetricMiddleware
to the top of yourMIDDLEWARE
to get count metrics - Add
django_statsd.middleware.StatsdLatencyMetricMiddleware
to the top of yourMIDDLEWARE
to get latency metrics
Logger
Used to track occurrence of a specific event
from django_statsd.logger import StatsdLogger
# some process ran with error
StatsdLogger.incr('process_a_error')
# process error resolved
StatsdLogger.decr('process_a_error')
Build the package
Build Requirements
- Make
- Python
Initialise Build Environment
One time initialisation
make init
Build and install locally
make dist
make install
Changelog
Please find the changelog here: CHANGELOG.md
Authors
django-statsd-prom-exporter-middleware was written by Kshitij Nagvekar.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_statsd_prom_exporter-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31eac72ae7599099f1229a17ffc5981948fef97690d229de9ead88b4595f7cf4 |
|
MD5 | 5508796b571ebbef2fd890f39584ff19 |
|
BLAKE2b-256 | ca54a4a8a76629bc08401610ef89019c72b68ee13beef854793e3fe939ea12d9 |