Class: Fluent::TextParser::GrokPure
- Inherits:
-
Parser
- Object
- Parser
- Fluent::TextParser::GrokPure
- Includes:
- TypeConverter
- Defined in:
- lib/fluent/plugin/parser_grok_pure.rb
Defined Under Namespace
Classes: LogProxy, PatternError
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ GrokPure
constructor
A new instance of GrokPure.
- #parse(text) ⇒ Object
Constructor Details
Instance Method Details
#configure(conf) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/parser_grok_pure.rb', line 29 def configure(conf) super if @grok_pattern_path Dir["#{@grok_pattern_path}/*"].sort.each do |f| @grok.add_patterns_from_file(f) end end begin @grok.compile(@grok_pattern, true) rescue Grok::PatternError => e raise PatternError, e. end end |
#parse(text) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/parser_grok_pure.rb', line 45 def parse(text) time = nil record = {} matched = @grok.match_and_capture(text) do |k,v| if k == @time_key time = @mutex.synchronize { @time_parser.parse(v) } else record[k] = @type_converters.nil? ? v : convert_type(k,v) end end if matched time ||= Engine.now if @estimate_current_event yield time, record else yield nil, nil end end |