Class: Fluent::GroongaQueryLogFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_groonga_query_log.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fluent/plugin/filter_groonga_query_log.rb', line 34

def configure(conf)
  super

  options = {
    :slow_operation_threshold => @slow_operation_threshold,
    :slow_response_threshold => @slow_response_threshold,
    :timezone => @timezone,
    :time_format => @time_format,
  }
  @parser = GroongaQueryLog::Parser.new(options)
end

#filter_stream(tag, event_stream) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fluent/plugin/filter_groonga_query_log.rb', line 46

def filter_stream(tag, event_stream)
  statistics_event_stream = MultiEventStream.new
  event_stream.each do |time, record|
    raw_data = record[@raw_data_column_name]
    next if raw_data.nil?
    @parser.parse(raw_data) do |statistic|
      statistic_record = create_record(statistic)
      statistics_event_stream.add(time, statistic_record)
    end
  end
  statistics_event_stream
end