Get specific fields from csv file

i am haing a csv file having 100 fields. i want to parse only 5 fields so i used Ruby filter and framed my conf. Upon executing getting {} in all lines instead of fields

Conf file

input{
file {
path => path_to_file
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
ruby {
code => "
wanted_fields = ['','']
event.to_hash.keys.each { |k|
event.remove(k) unless wanted_fields.include? k
}
"
}
}
output
{
stdout{}
}

Output:

{}
{}
{}
{}
{}

Thanks in advance

I suggest you use the prune filter for this.

You can parse your CSV with "CSV" filter option and then you can use "remove_field" to remove undesirable fields

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