Splunk Search

Search-time extraction works, new field extraction doesn't

snickered
Path Finder

I have a sourcetype that has multi-line events. An example looks like this:

Jan07 12:45:18.57 | [Info ] | This is the message I want
Stuff : foo
More Stuff: bar
I can successfully pull out my desired data using rex during a search with:
rex field=_raw "\[Info\s\]\s\|\s(?<msg>.*)"

When I use the same regex in manager->fields it doesn't work. It actually grabs everything in the event all the way to the end and doesn't stop at the end of the line. However when I use the interactive field extractor it works as expected and highlights only the message I want to extract. How do I make it stop at the end of the line rather than the end of the event?

0 Karma
1 Solution

vincesesto
Communicator

Hey Snickered,
I have set up some test data to match your logs and when I use the extra fields option, I am seeing a different value compared to yours. I am getting the following rex "(?i)\[.? \] \| (?P.)"

Secondly, do you have any other information defined in your props.conf file to define the event...This could also hold a key to what is happening.

Regards Vince

View solution in original post

0 Karma

vincesesto
Communicator

Hey Snickered,
I have set up some test data to match your logs and when I use the extra fields option, I am seeing a different value compared to yours. I am getting the following rex "(?i)\[.? \] \| (?P.)"

Secondly, do you have any other information defined in your props.conf file to define the event...This could also hold a key to what is happening.

Regards Vince

0 Karma

snickered
Path Finder

Yeah, the interactive thing gave me something along those lines also but it was matching way too much (I also have [Warn ], [Error ], etc...), so I had to use my rex which worked in the interactive field extractor but simply didn't when set as a field extraction through the manager.

Anyway, I got it working with this: \[Info\s\]\s\|\s(?P[^\r\n]+)

0 Karma
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!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...