Rail’s Analyzer with Klass
Download it: rawk.rb
run ruby rawk.rb -h for help.
I wanted to analyze Spongecell’s log file to see where the most of our cpu time was being used. I checked out rails-analyzer.rubyforge.org and after navigating myself in circles following the links I finally decided to download some stuff, install some gems, and give it a try. It didn’t work.
I didn’t understand why I needed whole packages just to look at one log file. I could get a lot of information from the logs just using grep. So I started to write a tool in awk until Tom told me I should use ruby.
Of course I should use ruby.
Rawk is the result. Many sets of data are presented and grouped in many ways. The first thing you will want to optimize are probably the actions that your server sepnds the most time on. I ran rawk on our log a few minutes ago:
The four most expensive requests for Spongecell are the poller (for keeping your calendar display up to date), iCalendar feeds from Spongecell, the normal web view of Spongecell, and RSS feeds.
Please give this tool a try and let me know what you think. I’m happy to include improvements or make modifications.
** This script is released as beerware, something I first heard about on a mac bittorrent client. They defined it as software that is free and if you like it you should buy yourself a beer.

November 13, 2006 at 8:38 pm
Thanks for the script. I gave it a try and it worked well. One recommendation is to change the name to something that reflects the purpose of the tool instead of its previous implementation. Cheers.
November 13, 2006 at 11:05 pm
Thanks for the comment. You’re right, perhaps Rawc – Rail Analyzer with Class – would have caused slightly less cringing from ex-awk users.
December 11, 2006 at 7:37 pm
I’m using the Robot Co-Op’s libraries. There are a few things that would be great in Rawc:
* A little more abstraction so you could use it to parse logs and then pump that data into a database for graphing over time
* An overall average requests per second
* A real-time option where it tails a live log and shows the actual requests per second being served up, like rails_stat
* A gem? (see Hoe for an easy way to make a Rubygem and register it as a command-line app)
December 13, 2006 at 12:43 am
Thanks for the script – it was great to be able to quickly confirm that our latest RoR app doesn’t have any slow pages.
February 22, 2007 at 3:08 pm
Wow. That was painfully simple to use and extremely useful. Thanks!
March 26, 2007 at 5:34 pm
[...] Ruby on Rails Log Analyzer – RAWK « ckh sponge Saving for the future – could be handy to have. (tags: rails ruby RoR rawk analyzer tools performance log) [...]
April 20, 2007 at 7:47 pm
This is nice, I was looking for a simple way to see how much traffic my new toy-app was getting and rails-analyzer looked like a lot of work and configuration for what I needed. This worked like a charm and was very speedy.
July 13, 2007 at 7:35 pm
rawk.rb is a great idea and I used it for a few months, but I needed all the features of pl_analyze.
I wrote an alternate logger that can be used simply with pl_analyze. I use it on every one of my sites now.
http://nubyonrails.com/articles/a-hodel-3000-compliant-logger-for-the-rest-of-us
August 8, 2007 at 11:25 pm
[...] Hobbs’ Rails Analyzer with Klass, or Rawk, is a painless rails log analyzer. Its a great tool to keep on hand. I know there is a [...]
August 11, 2007 at 3:08 pm
Thank you! Simple, clear and useful.
November 5, 2007 at 5:50 pm
Great tool! Just what I needed this morning to grab profile of activity.
Tks!
December 20, 2007 at 8:55 am
I would like to see a continuation of the topic
March 23, 2008 at 12:27 pm
[...] analizar los logs también tenemos otra pequeña herramienta que podemos instala, rawk es un script en Ruby que no necesita instalación ni configuración y nos puede dar unos muy buenos [...]
March 28, 2008 at 10:55 am
Rails > 2.0 uses the BufferedLogger instead of the normal logger, one way is to switch back to the old logger, but I wanted to find a way to stick with the new BufferedLogger.
Although not the most elegant of solutions, but you can just patch the add method of the BufferedLogger in case you want to keep it.
Create a file custom_logger.rb in your initializers folder and paste the content of the pastie in it (it only puts pid in the log message in production mode, it’s less ugly):
http://pastie.caboo.se/171954
April 7, 2008 at 8:51 pm
[...] El primero que he encontrado es RAWK: [...]
September 16, 2008 at 3:24 pm
[...] Auf der Seite : http://ckhsponge.wordpress.com/2006/10/11/ruby-on-rails-log-analyzer-rawk/ [...]
February 11, 2009 at 8:37 pm
Please have a look at request-log-analyzer, another tool to analyze your Rails log files. I may not be fully objective as the author, but I think the reports request-log-analyzer producers are superior to those of rawk. Moreover, no special logger is needed.
Another advantage is that you can adjust the log parser easily to support log messages that are unique to your applications (locales, what user is logged in, etc).
See the request-log-analyzer project wiki for more information.
March 3, 2009 at 3:40 pm
[...] looking at the logs, using rawk to analyze the top offenders, I was unable to find any particular controllers or actions that were [...]
April 17, 2009 at 1:08 pm
it seems to be parsing the log properly but shows no numbers
the columns on the right are all zeros
what is wrong?
April 17, 2009 at 6:19 pm
Do you have the latest version of rawk?
http://github.com/whatcould/rawk/tree/master
Rails 2 changed the log format so that could be the problem.
April 17, 2009 at 8:02 pm
1.2 is the version I have