All Apps and Add-ons

rex everything after 8th whitespace

subtrakt
Contributor

2014-02-01T14:51:24.601752+00:00 .foo.com 21470: Feb 1 14:51:23.570 GMT: %SEC-6-IPACCESSLOGP:

I looked around but couldn't find a rex query to extract the actual Syslog message which would be after the 8th colon in the above message or 8th whitespace will also work.

rex generator isn't giving the desired results.

Thanks in advance for any help.

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You could prefix the expression with one that matches eight whitespaces:

^(\S*\s){8}(?<everything_after>.*)$

View solution in original post

mikaelbje
Motivator

This field has already been extracted and is called "message_text". If you want to do some magic on the contents of it, just reference that field from the rex command instead of _raw.

I wouldn't recommend you to do a rex after the 8th colon as there is no guarantee there will be eight colons in a IOS syslog message. It all depends on how the logging from the device is set up.

Regards,

Mikael

Author of the Cisco IOS app

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You could prefix the expression with one that matches eight whitespaces:

^(\S*\s){8}(?<everything_after>.*)$

martin_mueller
SplunkTrust
SplunkTrust

That works the same way, just replace \S with [^:] and \s with :

0 Karma

subtrakt
Contributor

What about after 8th ':'

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Right - I had one closing parenthesis too many after {8}... adding one in front works as well of course.

For learning and testing, take a look at http://www.regexr.com/

0 Karma

subtrakt
Contributor

rex ^((\S*\s){8})(?.*)$ --- Added another '(' after '^' and it works like a dream! Thanks! Do you recommend any regex cheatsheets or learning resources?

Get Updates on the Splunk Community!

New Case Study: How LSU’s Student-Powered SOCs and Splunk Are Shaping the Future of ...

Louisiana State University (LSU) is shaping the next generation of cybersecurity professionals through its ...

Splunk and Fraud

Join us on November 13 at 11 am PT / 2 pm ET!Join us for an insightful webinar where we delve into the ...

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...