Splunk Search

How to extract value of a required field using regx?

hrishi_deshpand
Explorer

msg INFO | 2021-10-14 10:38 PM |  Message consumed: {"InputAmountToCredit":"22.67","CurrencyCode":"AUD","Buid":"1401","OrderNumber":"877118406","ID":"58916"}

In above sample data, I want to extract "InputAmount" to credit.  Also I wan to extract "ID" and perform another search to get its status (as status is in another event and needs to be extracted by mapping ID) 

This is for logs and I have lots of events to perform search on to generate report.

Any help would be appreciated.

Labels (4)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@hrishi_deshpand 

Can you please try this?

YOUR_SEARCH
|rex field=_raw "\"InputAmountToCredit\":\"(?<InputAmountToCredit>[^\"]+).+\"ID\":\"(?<ID>[^\"]+)"

 

My Sample Search :

| makeresults 
| eval _raw="msg:  INFO | 2021-10-14 10:38 PM |  Message consumed: {\"InputAmountToCredit\":\"22.67\",\"CurrencyCode\":\"AUD\",\"Buid\":\"1401\",\"OrderNumber\":\"877118406\",\"ID\":\"58916\"}"
|rex field=_raw "\"InputAmountToCredit\":\"(?<InputAmountToCredit>[^\"]+).+\"ID\":\"(?<ID>[^\"]+)"


 Thanks
KV
▄︻̷̿┻̿═━一   😉

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...