Splunk Search

Regex three lines with same format to create three field extractions

Bliide
Path Finder

I am trying to pull specific lines from a log file. I have a format that is repeated and I have a regex that is pulling the info from those lines. My problem is that there are 3 lines that have the same format. I need a way to pull each line separately. The REGEX I am using for the field extraction looks like this:

(?i)^(?:[^:]*:){3}(?P[log_error].+)

The regex works but it is pulling lines that have LOG ERROR, LOG INFO and LOG EXCEPTION. The logs look like this:

LOG ERROR:6/6/2014 3:37 PM:

LOG INFO:6/6/2014 3:37 PM:

LOG EXCEPTION:6/6/2014 3:37 PM:

I have tried putting text into the REGEX for each line but I must be inputting something incorrectly. My goal is to create three field extractions (logerror, loginfo and logexcept). I know I just need to add a simple text match to the REGEX but I cannot figure out what I am doing wrong.

0 Karma

landen99
Motivator

I recommend:

(?i)^LOG\s*(?P<log_info>[^:]*):(?P<log_date>[^:]*)

as an automatic field extraction if the events are separated. Otherwise you need to fix the indexing so that the events are separated.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Give this a try

Your base search | rex "(?i)^LOG (INFO(?:[^:]*:){3}(?P<loginfo>.+)|ERROR(?:[^:]*:){3}(?P<logerror>.+)|EXCEPTION(?:[^:]*:){3}(?P<logexcept>.+))"
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...