Monitor Your Python App With FnordMetric and pyfnordmetric

FnordMetric is a super cool (and sexy) real-time event monitoring app.

I’m currently using it for the next version of fidofetch. It’s great for tracking events and monitoring background workers.

It also has a great way to watch how a user uses your application:

You can see what events are caused by a user and all kinds of cool stuff.

I have a fork of FnordMetric here with a basic change to unclutter the users screen a bit.

Configuration

FnordMetric is written in Ruby on top of event machine. It’s super easy to get running.

First you describe a gauge, basically a counter:

gauge :logins_per_hour,
    :tick  => 1.hour.to_i,
    :title => 'Logins per Hour'

Then you need an event handler:

event(:api_login) { incr(:logins_per_hour) }

And finally some way to display it

widget 'API', {
    :title            => 'Logins Per Hour',
    :type             => :timeline,
    :gauges           => :logins_per_hour,
    :include_current  => true,
    :autoupdate       => 60 # refresh graph every minute
  }

You can have multiple time series per chart, auto-refreshing of data, top-lists, bar charts and more.

There’s so many ways to display your data, a full blown example is over here.

Getting Data In

There are a few ways to get data into FnordMetric. You can use the HTTP API, send data over a TCP connection or a Redis queue.

FnordMetric is actually backed by Redis so the fastest way to get data in is to talk directly to the backend.

For this I wrote a python module cleverly named pyfnordmetric.

Just easy_install pyfnordmetric and start using the Fnordmetric module like so:

from fnordmetric import Fnordmetric

  fnord = Fnordmetric("localhost", 6379) # Redis server
  fnord.event("saw_unicorn")

Tracking Users

That’s pretty useful in it’s own right, but one of the cool features of FnordMetric is that it allows you to see what a specific visitor is doing on your site right now. For this there are a couple more features:

fnord.event("login", "session1234")
  fnord.set_name("Stephen Holiday", "session1234")
  fnord.set_gravatar("[email protected]", "session1234")

That code will automatically grab a users Gravatar if they have one and display it on the FnordMetric window:

Conclusion

FnordMetric has been a great help in debugging issues with Fidofetch and I want to thank the developers for their hard work. I’d also like to thank Kirk Scheibelhut for telling me about the project.

There’s so much more you can do with FnordMetric. There is support for different charts, three dimensional data and other goodies. It’s definitely worth browsing around the repository for cool features.

I’m working on a few others tools to get more data into FnordMetric with posts in the works.

Let me know what you think.