Class: LogStash::Outputs::CSV

Inherits:
File show all
Defined in:
lib/logstash/outputs/csv.rb

Overview

CSV output.

Write events to disk in CSV or other delimited format Based on the file output, many config values are shared Uses the Ruby csv library internally

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from File

#teardown

Methods inherited from Base

#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/logstash/outputs/csv.rb', line 33

def receive(event)
  return unless output?(event)
  path = event.sprintf(@path)
  fd = open(path)
  csv_values = @fields.map {|name| get_value(name, event)}
  fd.write(csv_values.to_csv(@csv_options))

  flush(fd)
  close_stale_files
end

#registerObject



27
28
29
30
# File 'lib/logstash/outputs/csv.rb', line 27

def register
  super
  @csv_options = Hash[@csv_options.map{|(k,v)|[k.to_sym, v]}]
end