1
votes

I am very new to Logstash and ELK in general. I need to write a grok pattern for a log file in the following format :

[191114|16:51:13.577|BPDM|MDS|2|209|ERROR|39999]Interrupted by a signal!!!

I tried to write a grok pattern by referring grok-patterns and by trying out my implementation in grok-debugger, but it didn't work.

grok {
match => { "message" => "%{NONNEGINT:fixed}|%{HOSTNAME:host}|%{WORD:word1}|%{WORD:word2}|%{NONNEGINT:num1}|%{NONNEGINT:num2}|%{ERROR|INFO|EVENT}|%{NONNEGINT:num1}|%{GREEDYDATA:message}" }
 }
1

1 Answers

2
votes

You need to escape the brackets and the pipes, and your second field is not a host, it is a time.

This one works, just validate the field names.

\[%{NONNEGINT:fixed}\|%{DATA:time}\|%{WORD:word1}\|%{WORD:word2}\|%{NONNEGINT:num1}\|%{NONNEGINT:num2}\|%{WORD:loglevel}\|%{NONNEGINT:num3}\]%{GREEDYDATA:message}

This grok will parse your message like this.

{
  "word1": "BPDM",
  "word2": "MDS",
  "message": "Interrupted by a signal!!!",
  "loglevel": "ERROR",
  "num1": "2",
  "fixed": "191114",
  "time": "16:51:13.577",
  "num3": "39999",
  "num2": "209"
}