class Fluent::SomeOutput
Public Instance Methods
configure(conf)
click to toggle source
This method is called before starting.
Calls superclass method
# File lib/fluent/plugin/out_coralogix.rb, line 24 def configure(conf) super begin @loggers = {} #If config parameters doesn't start with $ then we can configure Coralogix logger now. if !appname.start_with?("$") && !subsystemname.start_with?("$") @logger = CoralogixLogger.new privatekey, appname, subsystemname @configured = true end rescue Exception => e $log.error "Failed to configure: #{e}" end end
emit(tag, es, chain)
click to toggle source
This method is called when an event reaches Fluentd. 'es' is a Fluent::EventStream object that includes multiple events. You can use 'es.each {|time,record| … }' to retrieve events. 'chain' is an object that manages transactions. Call 'chain.next' at appropriate points and rollback if it raises an exception.
NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
# File lib/fluent/plugin/out_coralogix.rb, line 91 def emit(tag, es, chain) chain.next es.each {|time,record| logger = get_logger(record) log_record = log_key_name != nil ? record.fetch(log_key_name, record) : record log_record = is_json ? log_record.to_json : log_record log_record = log_record.to_s.empty? ? record : log_record #puts log_record logger.debug log_record } end
extract(record, key, default)
click to toggle source
# File lib/fluent/plugin/out_coralogix.rb, line 38 def extract record, key, default begin res = record return key unless key.start_with?("$") key[1..-1].split(".").each do |k| res = res.fetch(k,nil) return default if res == nil end return res rescue Exception => e $log.error "Failed to extract #{key}: #{e}" return default end end
get_app_sub_name(record)
click to toggle source
# File lib/fluent/plugin/out_coralogix.rb, line 54 def get_app_sub_name(record) app_name = extract(record, appname, DEFAULT_appname) sub_name = extract(record, subsystemname, DEFAULT_subsystemname) return app_name, sub_name end
get_logger(record)
click to toggle source
# File lib/fluent/plugin/out_coralogix.rb, line 60 def get_logger(record) return @logger if @configured app_name, sub_name = get_app_sub_name(record) if !@loggers.key?("#{app_name}.#{sub_name}") @loggers["#{app_name}.#{sub_name}"] = CoralogixLogger.new privatekey, app_name, sub_name end return @loggers["#{app_name}.#{sub_name}"] end
shutdown()
click to toggle source
This method is called when shutting down.
Calls superclass method
# File lib/fluent/plugin/out_coralogix.rb, line 80 def shutdown super end
start()
click to toggle source
This method is called when starting.
Calls superclass method
# File lib/fluent/plugin/out_coralogix.rb, line 75 def start super end