Class: Fluent::MySQLSlowQueryInput

Inherits:
TailInput
  • Object
show all
Defined in:
lib/fluent/plugin/in_mysql_slow_query.rb

Instance Method Summary collapse

Instance Method Details

#configure_parser(conf) ⇒ Object



23
24
25
# File 'lib/fluent/plugin/in_mysql_slow_query.rb', line 23

def configure_parser(conf)
  @parser = MySlog.new
end

#receive_lines(lines) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/in_mysql_slow_query.rb', line 27

def receive_lines(lines)
  es = MultiEventStream.new
  @parser.divide(lines).each do |record|
    begin
      record = @parser.parse_record(record)
      if time = record.delete(:date)
        time = time.to_i
      else
        time = Time.now.to_i
      end
      es.add(time, record)
    rescue
      $log.warn record, :error=>$!.to_s
      $log.debug_backtrace
    end
  end

  unless es.empty?
    begin
      Engine.emit_stream(@tag, es)
    rescue 
    end
  end
end