Splunk Search

Problem with the simplest rex

rachelneal
Path Finder

I have several error logs that have a similar format:

Cannot set Single Use Prices on Single Room Standard Room (
Cannot set Single Use Prices on Single Room Standard Suite (
Cannot set Single Use Prices on Single Room Executive King Room (

The rex that I am attempting to use only returns a table of blank lines.

"Cannot set Single Use Prices on Single Room " |rex "(?<Error>\w+?)\(" | table Error

I've tried \w \w+ \w+? \. \.+ \.+?

Any suggestions?

Tags (3)
0 Karma
1 Solution

rachelneal
Path Finder

Thanks everyone. I ended up with rex "\"(?.+?(\d+?)).+?\'(?\d+?)\'.+?\'(?\d+?)\'" after getting rex "\"(?.+?(" to work. Woohoo!

View solution in original post

0 Karma

rachelneal
Path Finder

Thanks everyone. I ended up with rex "\"(?.+?(\d+?)).+?\'(?\d+?)\'.+?\'(?\d+?)\'" after getting rex "\"(?.+?(" to work. Woohoo!

0 Karma

hjwang
Contributor

try

| rex "(?<Error>[^\r\n\(]+)\("
0 Karma

Lowell
Super Champion

Is there a space between the last word and the "(". If so, your regex isn't going to match. Try:

| rex "(?\w+)\s+("

Lowell
Super Champion

That's true. It depends on what you are looking for. rachelneal, if you would provided additional details in your question (use the "edit" link below you question), then a more suitable regex could be suggested. Specifically, note what strings you would like to extract from the samples given.

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Also, \w will not match spaces, so all you're going to get is the word "Room" or "Suite".

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

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