Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Following are my log lines:

Timestamp: 27-05-2016 13:25:17
Title:Customer.GetCustomer()
Message: Searched Customers for number : 123
InnerException: An error has occurred
StackTrace: An error has occurred
Machine: PQR

Timestamp: 27-05-2016 13:25:17
Title:Customer.GetCustomer()
Message: Searching Customers for number : 123
Machine: PQR

Timestamp: 27-05-2016 13:25:17
Title:Customer.GetCustomer()
Message: Searching Customers for number : 123
StackTrace: An error has occurred
Some exception has taken place
Machine: PQR

Fields like 'InnerException' and 'StackTrace' are optional in my log. Following is the grok pattern which I have constructed, but its not working.

'InnerException' and 'Trace' are becoming part of 'Message' field, they are not getting created as separate fields, if present in log.

(?m)%{DATESTAMP:Timestamp}\s+%{TITLE:ServiceTitle}\s+%{MESSAGE:ServiceMessage}(\s+%{IEXCEPTION:InnerException})?(\s+%{TRACE:Trace})?\s+%{MACHINE:ServiceMachine}

The extra patterns used are:

TITLE ^\s*Title:.+
MESSAGE ^\s*Message:.+
IEXCEPTION ^\s*InnerException:.+
TRACE ^\s*StackTrace:.+
MACHINE ^\s*Machine:.\S+

The multi-line filter applied is:

^\Timestamp

Negate the multi-line regex:

True

Can you please tell me, what is wrong in my grok pattern? And how 'InnerException' and 'Trace' will get created as separate fields, if present in log lines.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.