Sha256: 7ac5158a774447d0d0601227bc71bb0e660f25ae0c51461085b135d26e051a51
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# encoding: utf-8 require "logstash/filters/base" require "logstash/namespace" # Execute ruby code. # # For example, to cancel 90% of events, you can do this: # [source,ruby] # filter { # ruby { # # Cancel 90% of events # code => "event.cancel if rand <= 0.90" # } # } # class LogStash::Filters::Ruby < LogStash::Filters::Base config_name "ruby" # Any code to execute at logstash startup-time config :init, :validate => :string # The code to execute for every event. # You will have an `event` variable available that is the event itself. config :code, :validate => :string, :required => true public def register # TODO(sissel): Compile the ruby code eval(@init, binding, "(ruby filter init)") if @init eval("@codeblock = lambda { |event| #{@code} }", binding, "(ruby filter code)") end # def register public def filter(event) return unless filter?(event) @codeblock.call(event) filter_matched(event) end # def filter end # class LogStash::Filters::Ruby
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstash-filter-ruby-0.1.5 | lib/logstash/filters/ruby.rb |
logstash-filter-ruby-0.1.4 | lib/logstash/filters/ruby.rb |
logstash-filter-ruby-0.1.3 | lib/logstash/filters/ruby.rb |