Logstash Filter development: rspec test for filter success/failure

(Ferdinand Holzer) #1


i couldn't find a way to test for filter success, i.e. whether the filter_matched method was called on an event. I tried to find this by looking at the tests of some of the official filter plugins but couldn't find anything. I noticed the raise_error check, but that's about exception... I'm only interested in whether filter_matched was called.
This is my spec so far: https://github.com/fholzer/logstash-filter-real_ip/blob/master/spec/filters/real_ip_spec.rb

I'm new to ruby, so any help is highly appreciated.


(Ferdinand Holzer) #2

Found a workaround. For anyone having the same issue, use an add_field directive in your filter config block, then test whether the field was added.



(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.