Save arrays as csv output put

Hello,

In my system, I input a very long log using filebeat ( has about 3000 characters in a single log line)
I need to use logstash to save this log in a csv file.
I need to save the log as multiple comma-separated columns by splitting in to separate 300 character elements.
I was able to create the needed array with a ruby code.
But when I use the csv output plugin to print the array into separate csv files it is not working properly. The whole array is printed in a single csv column.

My Code is as follows.

input {
    beats {
      host => "localhost"
      port => 5043
    }
}

filter {
 ruby {      
        code => "
        def chunk(string, size)
          string.scan(/.{1,#{size}}/)
        end
        vararr = chunk(event.get('[message]'),300)
        event.set('responsearr', vararr)"
  }
  mutate { remove_field => [ "message"] } 
}


output {
  csv {
    path => "/var/csv_reports/test.csv"
    fields => ["responsearr"]
  }
}

what am I doing wrong ?

Hello,

I tried many approaches and was unable to find a solution.
So I manually edited the "logstash-output-csv" repo and added the customized plugin.
Now my requirement is a completed successfully.

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.