Issue in using Grok gem

Hi All,

I wanted to parse a log file, so came across Grok. Installed the gem and
tried the below example that is given in the documentation below:

require ‘grok’

configure do |c|
c.file = “/var/log/auth.log”
c.interval = 2
c.replay = 0
end

When i run the above code, i get the following error:

C:\examples\code\grok>ruby parselog.rb
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in
require': C:/Ruby192/lib/ruby/gems/1.9.1/gems/grok-0.0.5/lib/grok/watcher.rb:121: syntax C:/Ruby192/lib/ruby/gems/1.9.1/gems/grok-0.0.5/lib/grok/watcher.rb:137: syntax error, unexpected keyword_end, expecting $end from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:inrequire’
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/grok-0.0.5/lib/grok.rb:1:in <top (required)>' from <internal:lib/rubygems/custom_require>:33:inrequire’
from internal:lib/rubygems/custom_require:33:in rescue in require' from <internal:lib/rubygems/custom_require>:29:inrequire’
from parselog.rb:1:in `’

What has gone wrong here?

Hi All,
Any thoughts on above issue?

thanks in advance.

c.replay = 0
syntax error, unexpected keyword_end, expecting $end
from parselog.rb:1:in `’

What has gone wrong here?

On 06/25/2013 11:14 AM, Rochit S. wrote:

Hi All,
Any thoughts on above issue?

thanks in advance.

If you look at the source code
(grok/lib/grok/watcher.rb at master · rodjek/grok · GitHub)
you will see that the syntax used is no longer valid in Ruby 1.9 (ending
an if conditional with a colon).

Since the code hasn’t been touched in three years, I think you are
looking at an outdated gem here.

You may want to fork it and fix it up to be Ruby 1.9 compatible or open
an issue on GitHub to poke the original author.

-Justin