jordansissel / ruby-grok

Pure-ruby implementation of grok.
Apache License 2.0
54 stars 25 forks source link

Coerce on nil values is creating unnecessary captures #18

Closed suyograo closed 9 years ago

suyograo commented 9 years ago

I found this while debugging https://github.com/elastic/logstash/issues/2897

A pattern like: (N/A|%{BASE10NUM:duration:int}ms) needs to only extract duration if the input text is like 24ms and not have the capture when the input text is N/A. Currently, this will output duration=0 which is not expected

The previous versions of grok were handling this correctly. This was a side effect of the optimization changes we did in https://github.com/jordansissel/ruby-grok/pull/11