Splunk Search

Event break regex - match 19 digit number

himynamesdave
Contributor

Happy New Year everyone!

Regex n00b here - I am struggling to break events for a particular source. Any help would be appreciated.

The line to break events is in the following format

"From <19 digit numeric string>@<misc alpha numeric string of varying length> <timestamp>"

For example:

From 1489304828131889971@xxx Sat Jan 03 07:02:43 2015

From 1489220782115942636@82hs Fri Jan 02 08:46:51 2015

I want to specify an event break in props.conf with "From <19 digit numeric string>@".

Can anyone help?

-dave

0 Karma
1 Solution

MuS
Legend

Hi himynamesdave,

try something like this as line breaker regex :

From\s.+?@

based on the assumption I understood you correct and you want everything after the @ as new line 😉

cheers, MuS

View solution in original post

eddit0r
Explorer

For the LINE_BREAKER to work there needs to be a capture group.

You should specify the following in props.conf

props.conf
SHOULD_LINEMERGE = FALSE
LINE_BREAKER = ([\r\n]+)From\s\d+@

That will break where there is a carriage return or new line, followed by From 'space' any number of digits and an @ symbol.

See how you go.

(It is always preferable to delimit multi-line events with LINE_BREAKER as it has significant benefits to processing speed)

0 Karma

jayannah
Builder

Since you want to break the events "From <19digits>@", here is props.conf for the same.
I have used \d{19} to match the exact 19 digits as you mentioned.


props.conf
[< your sourcetype OR source or host >]
BREAK_ONLY_BEFORE=From\s+\d{19}@
NO_BINARY_CHECK=1
SHOULD_LINEMERGE=true


please let me know if the above props.conf worked for you..
regex query tried to match the correct pattern is https://regex101.com/r/kD3tZ1/1

0 Karma

MuS
Legend

This will not work on any event NOT containing exactly (meaning more/less) 19 digits...
Always build things so you can [remember what they mean|work], two years from now 😉

0 Karma

jayannah
Builder

Yes, I knew it. It depends on whether strict or loose pattern matching required. That why I said, based on 19 digit pattern as per the question.

0 Karma

MuS
Legend

Hi himynamesdave,

try something like this as line breaker regex :

From\s.+?@

based on the assumption I understood you correct and you want everything after the @ as new line 😉

cheers, MuS

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...