class Fluent::TextParser::ElasticsearchSlowIndexingLogParser

Constants

REGEXP
TIME_FORMAT

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_es_slow_indexing.rb, line 9
def initialize
  super
  @time_parser = TextParser::TimeParser.new(TIME_FORMAT)
  @mutex = Mutex.new
end

Public Instance Methods

parse(text) { |nil, nil| ... } click to toggle source
# File lib/fluent/plugin/parser_es_slow_indexing.rb, line 19
def parse(text)
  m = REGEXP.match(text)
  unless m
    if block_given?
      yield nil, nil
      return
    else
      return nil, nil
    end
  end

  shard = m['shard'].to_i
  took_millis = m['took_millis'].to_i
  indexing_id= m['indexing_id'].to_i
  routing = m['routing'].to_i

  time = m['time']
  time = @mutex.synchronize { @time_parser.parse(time) }

  record = {
    'severity' => m['severity'],
    'source' => m['source'],
    'node' => m['node'],
    'index' => m['index'],
    'shard' => shard,
    'took' => m['took'],
    'took_millis' => took_millis,
    'type' => m['type'],
    'indexing_id' => indexing_id,
    'routing' => routing,
    'source_body' => m['source_body']
  }
  record["time"] = m['time'] if @keep_time_key

  if block_given?
    yield time, record
  else
    return time, record
  end
end
patterns() click to toggle source
# File lib/fluent/plugin/parser_es_slow_indexing.rb, line 15
def patterns
  {'format' => REGEXP, 'time_format' => TIME_FORMAT}
end