Splunk Search

Regex Help

tkerr1357
Path Finder

Hello all,

I am new to regex and struggling to get the Actual value field. I only need the number in between the quotes as sometimes the number can be smaller or larger than the example in the event. Below is an example of what I was trying with no luck. Any help is appreciated.
| rex "\svalue\":(?\d+)"

Message={
"ApplicationId": "babe7022-5a00-4338-a519-0a5bbf5c64ee",
"ApplicationName": "Lacerte 2019",
"Measurement": "lacerteload_2019",
"Description": "Measurement duration (59.615s) exceeded threshold of 40s (49.04%)",
"Actual value": "59.615",

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try | rex "value\\": \\"(?<actualValue>[^\\"]+)".

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

codebuilder
Influencer

There is a often overlooked utility that is extremely useful for these type situations..."erex".

Run your existing search and pipe the results to erex, give the field a name, and provide an example value.

e.g.
| erex ApplicationId examples="babe7022-5a00-4338-a519-0a5bbf5c64ee"

When the search returns, go to the job inspector and it will provide the regex that Splunk used to find the value.
You can also use "counterexamples" to eliminate matches.

It's a very handy tool.

Documentation:
https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Erex

----
An upvote would be appreciated and Accept Solution if it helps!
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try | rex "value\\": \\"(?<actualValue>[^\\"]+)".

---
If this reply helps you, Karma would be appreciated.
0 Karma

tkerr1357
Path Finder

no such luck. It returned Error in 'SearchParser': Missing a search command before '^'. Error at position '107' of search query 'search index="login_pi" source="WinEventLog:LoginP...{snipped} {errorcontext = (?[^\"]+)"}'.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There was a typo and extra escape characters were needed. Try the updated answer.

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