Techblog

Tech Blog

Our latest geek adventures!

15 August Rails log analyzer

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: , , ,

5 Responses to “Rails log analyzer”

  1. aleco Says:

    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.

  2. Willem Says:

    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_hasher method in analyze.rb. You could add a line similar to url.gsub!(/\/markets\/\w+/, '/markets/:id')

    You can get more than ten results by passing -c 50 to the command line, which will yield the top 50 results for every statistic.

  3. aleco Says:

    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).

  4. Willem van Bergen Says:

    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 -c configuration 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!

  5. Floorplanner Tech Blog » Blog Archive » Rails log analyzer matures Says:

    [...] I announced rails-log-analyzer some weeks ago, quite a lot has happened! Apparently there is some interest in [...]

Leave a Reply