Splunk Search

How to extract a field with special characters?

mugilbala
Engager

Hi,

I have a log statement that prints service execution time like -

Service Response : {"entity":"{\"transactionId\":\"39182d7a-7f34-4c28-a0f2-9b42b9b206df\",\"executionTimeInMillis\":112,"status":201}

I am trying to extract the value of "executionTimeInMillis".

My search statement - index="xyz" "Service Response :" | search "\"executionTimeInMillis\"\":"(?exeTime[^\$]*)," | table _time, exeTime
Note: I have added <> to exeTime. It is not showing in the question.

However, it did not show any results. Can you help me with this query?

0 Karma
1 Solution

somesoni2
Revered Legend

The field extraction command is rex, not search. There may be few issues with your regex, e.g. there is no double quotes after colon. So try this

index="xyz" "Service Response :" | rex "\"executionTimeInMillis[^\:]+\:\s*(?<exeTime>[^,]+)" | table _time, exeTime

View solution in original post

0 Karma

somesoni2
Revered Legend

The field extraction command is rex, not search. There may be few issues with your regex, e.g. there is no double quotes after colon. So try this

index="xyz" "Service Response :" | rex "\"executionTimeInMillis[^\:]+\:\s*(?<exeTime>[^,]+)" | table _time, exeTime
0 Karma

mugilbala
Engager

Thank you so much. It worked. Appreciate your help.

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