Splunk Search

Trouble extracting field using regex

gopx101
New Member

I'm having an issue using regex to extract some _raw data and I hope someone can help me.

The below regex examples works successfully in a regex checker but not in Splunk.

Regex:
^(?:query\/time\",\"value\":)(?P\d+) OR
^(query\/time\",\"value\":)(?P\d+)

Data from Splunk _raw
"query/time\",\"value\":319

In this example I need to place 319 into variable query_time

Thanks in advance to anyone that can provide a regex that will work in Splunk.

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

\"query\/time[^\:]+\:(?<YourFieldNameHere>\d+)

View solution in original post

0 Karma

pruthvikrishnap
Contributor

Try this :(.*)$
Let me know if this works

0 Karma

somesoni2
Revered Legend

Give this a try

\"query\/time[^\:]+\:(?<YourFieldNameHere>\d+)
0 Karma

lakromani
Builder

Are you sure you need to escape the : ?
Your suggestion

[^\:]+\:

I think this should work

[^:]+:
0 Karma

gopx101
New Member

This worked perfectly. Thank you.

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