django-zesty-metrics is a middleware suite that uses statsd to report important metrics to a StatD server.
Out of the box, it will track:
- response times individually by view, and in aggregate
- aggregate user activity data
With some minor configuration, it will track:
- individual user activity data
- arbitrary metrics
- Django >= 1.9
- statsd == 1.0 (StatsD client; GitHub <https://github.com/jsocol/pystatsd>)
- Graphite server (docs)
- Statsd server (blog post)
Install with pip install django-zesty-metrics.
Alternately, clone the git repository and execute python setup.py install within.
In your Django settings: - Add
zesty_metrics.apps.ZestyMetricsConfig
to theINSTALLED_APPS
- Addzesty_metrics.middleware.MetricsMiddleware
toMIDDLEWARE_CLASSES
- Set the following, as needed:STATSD_HOST
, defaultlocalhost
STATSD_PORT
, default8125
STATSD_PREFIX
, defaultNone
ZESTY_TRACKING_CLASSES
, default['zesty_metrics.tracking.UserAccounts']
Run
manage.py migrate
.
Set up a cron job to run the report_metrics
django-admin.py
command regularly. At least once a day, but you can update it as often
as you want. This command reports metrics from the trackers that you
configure in ZESTY_TRACKING_CLASSES
.
If you want to send metrics from the client-side, hook up the default URLs in
your urls.py
:
urlpatterns = [ url(r'^metrics/', include('zesty_metrics.urls')), ]
Lots of ideas were taken from django-statsd and django-munin.
- 0.4: - added support for Django-native migrations and other updates for Django 1.9+ compatibility.
- 0.3.1: - Added missing migrations and management commands.
- 0.3: - Added tests! Many things that didn't work now work. - Added DailyActivityRecord for tracking daily activity.
- 0.2: Added latency tracking, myriad bug-fixes.
- 0.1.1: Fixed "NO VALUE" error in
report_metrics
command when values were pulled from the cache. - 0.1: Initial release