Hi,
I need to parse a csv file which contains some dynamic headers/Columns. (lets say)
Header format-1: Column-1, Column-2, Collumn-3, X
Header format-2: Column-1, Column-2, Collumn-3, Y
These files are generated every 5 minutes and some have header format-1 while others have header format-2. Without opening the files, we cant say whether they would have Header format-1 or header format-2 (ie nothing in their name suggests if they are of either type).
The header is part of the csv file (ie first line), so I have tried some conditional statements to identify which format is the file and assign path to a variable that i can use to ascertain which file has which format (something like below)
filter {
if [message] =~ /^Column-1, Column-2, Collumn-3, X/
{ mutate {
add_field => { "File-Type-1" => "%{[path]}" }
}
However, since each line (within the csv) is parsed at a time, the above condition only picks up the header line only and doesnt work on the actual data.
Is there a way in logstash i can accomplish this task?
Thanks
sirsyedian