Splunk Search

Field extraction regex expression to pull information after a pattern

Bliide
Path Finder

I am trying to get regex working for a field extraction on some SSRS logs I have indexed in our deployment. My goal is to extract the data after INFO:. So in the below example, I am trying to extract Call to GetSystemPropertiesAction(). as a field I will label as INFO. Here is an example of one of the lines in the index:

library!ReportServer_0-370!3120!04/24/2015-10:49:19:: i INFO: Call to GetSystemPropertiesAction().

When I put the following regex into the regex101 application I extract the correct data:

(?<=INFO:).*

When I try to put that regex expression into the field extraction, it does not return any values in the preview.

Tags (2)
0 Karma

rsennett_splunk
Splunk Employee
Splunk Employee

Since you're asking Splunk to basically walk thru the event and find your match, it's not advisable to use something like any of the "lookbehind" directives because you want to move forward... not have the regex running back and forth looking for your stuff. Just for efficiency in parsing.

To create a field, you need a "named" capturing group... not just a capturing group (unless you're doing this in transforms, where you can specify the format and use a "hard code" filename with each capturing group.

Also, if the INFO: only appears where there IS definitely some info after it (I would imagine it is so) you don't have to use the super greedy * (zero or more) where + (one or more is perfectly acceptable)

INFO:(?P<INFO>.+)

For the most part... extracting fields best practices is

  • Find something to anchor on (in your case 'INFO:') and walk forward...

  • And if there is nothing to anchor to... start at the beginning of the event and walk forward until you get to the part you want to capture.

That is the most performant way to approach regex use in Splunk.

With Splunk... the answer is always "YES!". It just might require more regex than you're prepared for!
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Your regex string has no groups so nothing is extracted. Try this:

INFO:(?P<INFO>.*)
---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...