Class: Fluent::TextParser::ElasticsearchSlowIndexingLogParser
- Inherits:
-
Parser
- Object
- Parser
- Fluent::TextParser::ElasticsearchSlowIndexingLogParser
- Defined in:
- lib/fluent/plugin/parser_es_slow_indexing.rb
Constant Summary collapse
- REGEXP =
/^\[(?<time>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\]\[(?<severity>[a-zA-Z]+\s*)\]\[(?<source>\S+)\] \[(?<node>\S+)\] \[(?<index>\w+)\]\[(?<shard>\d+)\] took\[(?<took>.+)\], took_millis\[(?<took_millis>\d+)\], type\[(?<type>.+)\], id\[(?<indexing_id>.*)\], routing\[(?<routing>.*)\], source\[(?<source_body>.*)\]/- TIME_FORMAT =
"%Y-%m-%d %H:%M:%S,%N"
Instance Method Summary collapse
-
#initialize ⇒ ElasticsearchSlowIndexingLogParser
constructor
A new instance of ElasticsearchSlowIndexingLogParser.
- #parse(text) ⇒ Object
- #patterns ⇒ Object
Constructor Details
#initialize ⇒ ElasticsearchSlowIndexingLogParser
Returns a new instance of ElasticsearchSlowIndexingLogParser.
9 10 11 12 13 |
# 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 |
Instance Method Details
#parse(text) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 ⇒ Object
15 16 17 |
# File 'lib/fluent/plugin/parser_es_slow_indexing.rb', line 15 def patterns {'format' => REGEXP, 'time_format' => TIME_FORMAT} end |