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

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

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...