Metrics with Django and Redis

Published on 2013-05-19 02:38:29.648285+00:00
django   django-redis-metrics   metrics   redis  

So, you've got a shiny new Django-powered site, and now you'd like to start recording metrics. Perhaps you've read The Lean Startup, and you know you've got to know how people are using your site in order to know what to improve. Perhaps you're just a data nerd and you like to count things. Either way, there are ton's of ways to measure things on your site.

You could use third-party applications like Google Analytics or Mixpanel to see how people interact with your site. Then there are services like New Relic that give you amazing insights as to where your application is slow or too memory hungry. All of these services are really good, and if you're building a startup, you should be using them.

But sometimes, you need a little more flexibility when counting things. That's the motivation behind django-redis-metrics. It's a simple, lightweight Django app that lets you easily record metrics in your Django apps.

I use it on Work for Pie to measure things such as:

Once installed, it's fairly simple to start recording metrics. You can call out to the metric function anywhere in your code, and that will increment a counter every time the function is called.

from redis_metrics import metric

metric("thing-i-want-to-measure")

All data is stored in Redis (which is a great data store for this kind of thing). and there are very few dependencies. django-redis-metrics aims to be a fairly minimalistic, and very simple to use out of the box.

If you need a simple way to measure arbitrary events in a Django app, please give it a look.