Skip to content

Commit

Permalink
catch RegExp#match exceptions and log field/value information
Browse files Browse the repository at this point in the history
  • Loading branch information
fetep committed Jul 6, 2012
1 parent 7052973 commit ef3c990
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/logstash/filters/grok.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ def filter(event)

@logger.debug("Trying pattern", :pile => pile, :field => field )
(event[field].is_a?(Array) ? event[field] : [event[field]]).each do |fieldvalue|
grok, match = pile.match(fieldvalue)
begin
grok, match = pile.match(fieldvalue)
rescue Exception => e
fieldvalue_bytes = []
fieldvalue.bytes.each { |b| fieldvalue_bytes << b }
@logger.warn("Grok regexp threw exception", :exception => e.message,
:field => field, :grok_pile => pile,
:fieldvalue_bytes => fieldvalue_bytes)
end
next unless match
matched = true
done = true if @break_on_match
Expand Down

0 comments on commit ef3c990

Please sign in to comment.