I am trying to write grok pattern for my log file which has three different types of logs, I want to put a filter on the type names (TYPE1,TYPE2,TYPE3) and then write three different grok patterns for this one log file. Also, my log file is a csv separated file.
Log file:
TYPE1,word,word,word,num
TYPE2,word,word,word,word
TYPE3,num,word,num,word
Here's what I have tried so far:
filter {
if [message] =~ /TYPE1/ {
grok {
match => [ "message", "%{WORD:type},%{WORD:a1"},%{WORD:a2"},%{WORD:a3"},%{POSINT:a4"}]
}
}
}
This doesn't work. Also, in this config file i have written grok patterns for other files (which are working well) like:
filter {
if [type] == "sometype1" or [type] == "sometype2" {
grok {
match => [ "message", "%{POSINT:moduleid}%{SPACE}%{NUMBER:date}"]
}
}
}
And the logfile which is giving me problem has type=sometype3 which I have not mentioned anywhere.
Thanks