Class: Fluent::StatsdEventFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::StatsdEventFilter
- Defined in:
- lib/fluent/plugin/filter_statsd_event.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #filter(tag, time, record) ⇒ Object
-
#initialize ⇒ StatsdEventFilter
constructor
A new instance of StatsdEventFilter.
Constructor Details
#initialize ⇒ StatsdEventFilter
8 9 10 11 12 |
# File 'lib/fluent/plugin/filter_statsd_event.rb', line 8 def initialize super require 'statsd' require 'json' end |
Instance Method Details
#configure(conf) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fluent/plugin/filter_statsd_event.rb', line 24 def configure(conf) super @regexps = [] @grep.each do |regexp| begin @regexps << Regexp.compile(regexp) rescue RegexpError => e log.error "Error: invalid regular expression in grep: #{e}" end end @statsd = Statsd.new(@host, @port) end |
#filter(tag, time, record) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fluent/plugin/filter_statsd_event.rb', line 37 def filter(tag, time, record) if @record_key.nil? = record.to_json else if record[@record_key].is_a? String = record[@record_key].to_s else = record[@record_key].to_json end end if @regexps.empty? post_event(time, tag, ) else @regexps.each do |regexp| if ::Fluent::StringUtil.match_regexp(regexp, ) post_event(time, tag, ) break end end end record end |