My friend Bart from movesonrails.com just blogged about Rails log analyzer, a command line tool to get performance statistics for your Rails application by parsing its log file.
What started as an exercise for me to write a command line ruby program, has been extended and improved by Bart to be actually useful! We decided to release it under an MIT license. You can found the source on github. The project’s wiki contains usage information and an example of the output it will produce.
Tags: "rails-log-analyzer", rails, request-log-analyzer, statistics



August 16th, 2008 at 2:45 am
It’s a great plugin! I’ve just come across one problem so far: a route named
map.market ‘markets/:id’, :controller => ‘markets’, :action => ’show’
will not create an aggregated “/markets/:id/” in the statistics, but instead create one line per id. This might also be caused by using a custom to_param which isn’t integer (I havn’t checked if that’s the real reason for the problem yet).
Besides that it would be great to have an option to show more than the top10.
August 16th, 2008 at 7:14 am
Hi Aleco,
Currently, the analyzer will use some simple guesses to aggregate URLs. It does not use the Rails routing file. We are working on it to make it more reliable, but unfortunately it is not that easy. We are looking at it!
In the mean time, you can change how URLs are aggregated by changing the
request_hashermethod in analyze.rb. You could add a line similar tourl.gsub!(/\/markets\/\w+/, '/markets/:id')You can get more than ten results by passing
-c 50to the command line, which will yield the top 50 results for every statistic.August 16th, 2008 at 1:43 pm
Willem, thanks for the reply. I suggest to add the -c argument to the documentation.
As for the routes: I assume that if the code was bedded into a plugin/gem, it could then easily access the routes (and it would also know where to find the logfiles). It could then also add a rake or cap task, which would make it easier to aggregate the log analysis from your applications.
Alternatively, I could imagine passing a hash to analyze.rb for custom routes would be an option, which would then be feeded into the request_hasher method (as manually editing analyze.rb is a pain as you’d have to do it each time you publish a new version of analyze.rb).
August 16th, 2008 at 2:30 pm
Manually editing analyze.rb is a pain indeed. I would like to add some Rails integration to the tool to resolve these issues as well, but I already spent way too much time on this tool for now. First, I have to tune Floorplanner to get rid of all the performance issues I found with it
I added the
-cconfiguration option to the documentation and I have added your suggestions to the TODO file. If you have some spare time to hack on it, please do so!August 29th, 2008 at 11:50 am
[...] I announced rails-log-analyzer some weeks ago, quite a lot has happened! Apparently there is some interest in [...]