Greetings,
I am trying to create filter for my log file.
My log file is :
=-=-=-=-=-=-=-=-
Timestamp: Thursday, April 19, 2018 2:48:54 AM
Message: ID: 7
An exception of type 'System.Exception' occurred and was caught.
=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-
Timestamp: Thursday, April 19, 2018 2:48:54 AM
Message: ID: 8
An exception of type 'System.Exception' occurred and was caught.
=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=- denote start and end of my log file.
My config file is :
input {
beats {
port => "5044"
}
}
filter {
multiline {
pattern => "^=-=-=-=-=-=-=-=-"
negate => true
what => previous
}
grok {
match => [ "message", "Timestamp:\s%{DAY},\s%{MONTH}\s%{MONTHDAY},\s%{YEAR}\s%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}?" ]
add_field => {
"LogTimestamp" => "Timestamp:\s%{DAY},\s%{MONTH}\s%{MONTHDAY},\s%{YEAR}\s%{HOUR}:?%{MINUTE}(?::?%{SECOND})?%{ISO8601_TIMEZONE}?"
}
}
}
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
This is creating 2 documents(rows) for each log. One containing separator+log and other contains separator only.
(A) I want to delete the document containing only separator.
(B) I want to split the message field by creating new field 'LogTimestamp' that contain my Log timestamp and 'message' field contain rest of the message.
Like this: LogTimestamp: Thursday, April 19, 2018 2:48:54 AM Message: Message: ID: 7 An exception of type 'System.Exception' occurred and was caught.
I am beginner and new to grok patterns and filters. Please help,i am struck here from past 2 days. Also let me know if there is any proper documentation to learn about grok filters from.