Splunk Search

How to use regular expression to cut the beginning of an Exception message?

jward6004
Explorer

How to use regular expression for an Exception message from a Source=Windows:Application to cut the beginning of the message and display the just unique exception message?

 index=indexname source="WinEventLog:Application" CNBD Employee |  table _time, host, Exception_Message 

Exception_Message :

Dear CNBD Employee: If you see this exception, you should likely splash some cold water on your face and spring to action! The item_number BA11110 on hu_id MX99999 for wh_id ONT was not found. We need to fix this immediately else it might lead to undersells causing a revenue hit.

I'm looking to cut the beginning of my exception message and begin at the sentence below :

The item_number BA11110 on hu_id MX99999 for wh_id ONT was not found. We need to fix this immediately else it might lead to undersells causing a revenue hit.

I'm very green when using regular expression and am trying to get more comfortable using it in my searches

0 Karma
1 Solution

gokadroid
Motivator

How about trying this if you think its always the first sentence which you want to remove (assumption below is first sentence shall end in . OR ! OR ? which can be extended based on type of sentence ending punctuation):

index=indexname source="WinEventLog:Application" CNBD Employee 
| rex field=Exception_Message "^.*?(\.|\!|\?)\s*(?<exception>.*)"
| table _time, host, exception

See extraction here

View solution in original post

0 Karma

gokadroid
Motivator

How about trying this if you think its always the first sentence which you want to remove (assumption below is first sentence shall end in . OR ! OR ? which can be extended based on type of sentence ending punctuation):

index=indexname source="WinEventLog:Application" CNBD Employee 
| rex field=Exception_Message "^.*?(\.|\!|\?)\s*(?<exception>.*)"
| table _time, host, exception

See extraction here

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...