Class: Fluent::Plugin::JqOutput

Inherits:
Output
  • Object
show all
Includes:
JqMixin
Defined in:
lib/fluent/plugin/out_jq.rb

Constant Summary

Constants included from JqMixin

JqMixin::JqError

Instance Method Summary collapse

Methods included from JqMixin

#configure, included, #jq_transform, #shutdown, #start, #start_process

Instance Method Details

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fluent/plugin/out_jq.rb', line 32

def multi_workers_ready?
  true
end

#process(tag, es) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/out_jq.rb', line 36

def process(tag, es)
  new_es = Fluent::MultiEventStream.new
  es.each do |time, record|
  begin
    new_records = jq_transform tag: tag, time: time, record: record
    new_records = [new_records] unless new_records.is_a?(Array)
    new_records.each { |new_record| new_es.add time, new_record }
  rescue JqError
    log.error "Process failed with #{@jq}#{log.on_debug {' on ' + MultiJson.dump(record)}}, error: #{$!.message}"
  end
  end

  new_tag = tag.sub(/^#{Regexp.escape(@remove_tag_prefix)}\./, '')
  router.emit_stream(new_tag, new_es)
end