Splunk Search

How to convert a working rex statement to a field extraction?

ebailey
Communicator

Sample data:

12/28/2015 11:39:14.113 -0600
collection="MSMQ Queue"
object="MSMQ Queue"
counter="Messages in Queue"
instance="hostname"\private$\test_test_1062
Value=4

I have a working rex that extracts test_test_1062 to the following:

queueName=test_test_1062

using this rex:

| rex field=instance \\\(?<queueName>[^\\]+)$\"

If I try to convert this to a field extraction, I get the following error message

Encountered the following error while trying to update: In handler 'props-extract': Regex: unmatched parentheses

If I remove a slash from each group of slashes then I can save the field extraction, but then the result is not accurate and the last line is captured so I get this

queueName=test_test_1062 Value=4

The instance field has several variations, so I cannot get the IFX to work correctly once I load all the variations into it. Basically I just need all the text after private$ until a white space occurs, but I cannot figure out how to make that happen and also work as a field extraction.

Thanks!

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

This worked for me. I just replaced the '$' with '\s' to get everything until the next white space.

\\(?<queueName>[^\\]+)\s
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

This worked for me. I just replaced the '$' with '\s' to get everything until the next white space.

\\(?<queueName>[^\\]+)\s
---
If this reply helps you, Karma would be appreciated.

ebailey
Communicator

perfect - thanks

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...