rspec fails, but same in grok debugger works (tried on both 1.2.1 & 1.1.13)

Description

Given

&

http://grokdebug.herokuapp.com shows parse success.

However, the attached rspec script attached fails, for both 1.1.13 & 1.2.1 (in different ways).

1.1.3 fails to match.

1.2.1 fails with

If it works on grokdebug I'd expect it to work in RSpec. What am I doing wrong?

Thanks, M.

Attachments

2

Gliffy Diagrams

Activity

Show:

Martin Cleaver September 16, 2013 at 10:41 PM
Edited

Ok, so the quoting mistake came from https://github.com/logstash/logstash/wiki/Testing-your-filters

I've fixed this, and it now works. I also fixed up the wiki page.

Cheers, M.

PS. Script continues at

Jordan Sissel September 16, 2013 at 6:00 AM

I believe what Philippe has suggested for two fixes (using %q() and using 'tags' instead) is correct.

It is also important to note that the 'tags' field may not be present, if you expect that one tag not to be present in this simple example, you should insist { subject["tags"] }.nil?

Philippe Weber September 16, 2013 at 5:35 AM

1. I had a look in other logstash tests, since 1.2.x the event is not created with an empty tags arrays, so you should change your line

simply to

2. I had a similar issue in the past with grok test containing escaped characters, you should either double-escape them or use the %q{} syntax

http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#The_.25_Notation

Philippe Weber September 16, 2013 at 5:05 AM

You should not be able to run the same script on both version as, starting with 1.2.x, @tags has been changed to simply tags.
That would explain the nil, at least for the 1.2.1 version

Martin Cleaver September 15, 2013 at 7:12 PM

PS. I tend to run like this:

including the sed makes the yaml output semi-visible across lines. If there is a better way please let me know!

Details

Assignee

Reporter

Affects versions

Created September 15, 2013 at 7:03 PM
Updated September 16, 2013 at 10:53 PM