Parsing Text file with Pipe(|) separated fields

I am a newbie and started with Logstash
I have raw text file with data in the below format, with first row as Column headers and following with data separated with Pipe as delimiter.
I was trying to read the data and from file and parse as I needed, but I am getting "Provided Grok patterns do not match data in the input"

File Input:
StudentID|StudentName|StudentGrade
P0172069|StuLast1|A
P0172369|StuLast2|A+
P0172269|StuLast3|B
P0172169|StuLast4|C

Expected Output:
{
StudentID: P0172069
StudentName: StuLast1
StudentGrade: A

StudentID: P0172369
StudentName: StuLast2
StudentGrade: A+
......
}

Code:
//
filter {
mutate {
gsub => ["message","|"," "]
}
grok {
match => ["message","%{WORD:StudentID} %{WORD:StudentName} %{WORD:StudentGrade}" ]
}
}
//

I would suggest using a csv filter

 csv { autodetect_column_names => true separator => '|' }

Thanks Badger, your answer helped me start with a good step forward.
I had to do more changes but yours was the first brick.

Thanks again.

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