class LogStash::Outputs::CSV

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

Public Instance Methods

receive(event) click to toggle source
# 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
register() click to toggle source
Calls superclass method LogStash::Outputs::File#register
# File lib/logstash/outputs/csv.rb, line 27
def register
  super
  @csv_options = Hash[@csv_options.map{|(k,v)|[k.to_sym, v]}]
end

Private Instance Methods

get_value(name, event) click to toggle source
# File lib/logstash/outputs/csv.rb, line 45
def get_value(name, event)
  val = event[name]
  case val
    when Hash
      return val.to_json
    else
      return val
  end
end