* Watson Ruby on Rails log analyzer.
    Overview | Screenshots | RDoc

It's alpha, and it's slow. For a production.log like 1GB it may take even hour. So be prepared for that if you want to use it.


Watson is a Ruby on Rails log analyzer. It analyzes your production.log and tell you things like: More will come. It's alpha software, and strange things may happen.

Basic usage

You need a gruff library (gem install gruff), then you need to install watson:

script/plugin install http://watson.rubyforge.org/svn/watson/trunk/

Then you can just type:

rake watson:go

And.... you wait :) You know, Watson is a calm guy. He is never in a hurry and he needs time to get his job done properly (read more to find out why).

When it finishes you can view reports in log/watson/index.html. You may want to create some symlink to your public directory, but remember to put some password protection. There are some parts of your logs included in reports, and those may include some sensitive data.

How it works and why so slow

First your production.log is parsed and file tmp/watson.db is created. It's SQLite3 database containing your production.log parsed. Why like this? Log file cannot be kept in memory because it's usually too big (in my case it's like 1Gb when I have like no more than 100mb free memory availible). And parsing it every time we want to generate a different report also woudn't be a good soltion.

Instead of just watson:go you can run it all manually:

Create a tmp/watson.db sqlite database and needed table schema

rake watson:setup

Parse your production.log and put it to tmp/watson.db - that's the most expensive part and it takes some serious time.

rake watson:prepare

Once you have your logs parsed you can generate reports. It's also very easy to prepare your own reports, it would be great if you share them with us :)

rake watson:generate

Extending is simple

Just create an rhtml template in the templates directory (let's say my_page.rhtml), and in lib/generator.rb create a method that starts with page_. Get some data using LogEntry model and then just render template using a line like this:

generate "my_page", Proc.new {}

This Proc.new is to make your local vars from the method availible in your template. Output generated using default layout will be saved into log/watson/my_page.html

Questions and suggestions

Use tracker on the rubyforge project's page: http://rubyforge.org/projects/watson/

If you want to contact me directly try kacper.ciesla blah gmail