class Fluent::Plugin::AzureSearchOutput
Constants
- DEFAULT_BUFFER_TYPE
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_azuresearch.rb, line 35 def configure(conf) compat_parameters_convert(conf, :buffer) super raise Fluent::ConfigError, 'no endpoint' if @endpoint.empty? raise Fluent::ConfigError, 'no api_key' if @api_key.empty? raise Fluent::ConfigError, 'no search_index' if @search_index.empty? raise Fluent::ConfigError, 'no column_names' if @column_names.empty? @column_names = @column_names.split(',') @key_names = @key_names.nil? ? @column_names : @key_names.split(',') raise Fluent::ConfigError, 'NOT match keys number: column_names and key_names' \ if @key_names.length != @column_names.length end
format(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_azuresearch.rb, line 60 def format(tag, time, record) values = [] @key_names.each_with_index do |key, i| if key == '${time}' value = Time.at(time).strftime('%Y-%m-%dT%H:%M:%SZ') elsif key == '${tag}' value = tag else value = record.include?(key) ? record[key] : '' end values << value end [tag, time, values].to_msgpack end
formatted_to_msgpack_binary?()
click to toggle source
# File lib/fluent/plugin/out_azuresearch.rb, line 75 def formatted_to_msgpack_binary? true end
multi_workers_ready?()
click to toggle source
# File lib/fluent/plugin/out_azuresearch.rb, line 79 def multi_workers_ready? true end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_azuresearch.rb, line 55 def shutdown super # destroy end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_azuresearch.rb, line 49 def start super # start @client=Fluent::Plugin::AzureSearch::Client::new( @endpoint, @api_key ) end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_azuresearch.rb, line 83 def write(chunk) documents = [] chunk.msgpack_each do |tag, time, values| document = {} @column_names.each_with_index do|k, i| document[k] = values[i] end documents.push(document) end begin res = @client.add_documents(@search_index, documents) puts res rescue Exception => ex log.fatal "UnknownError: '#{ex}'" + ", data=>" + (documents.to_json).to_s end end