Getting Data In

Convert a string to table in splunk

bharat149
Explorer

Hi All i have result in the below format :
"From abc customerId YETNAKCNK, operation create,consumedUnits 0"
"From abc customerId YETNAKCNJ, operation update,consumedUnits 2"

I have to convert the below data to the following format : 
customerId               operation           consumedUnits

YETNAKCNK.             create                           0

YETNAKCNJ               update                          2

Labels (1)
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bharat149 

Can you please try this?

YOUR_SEARCH
| rex field=_raw "customerId (?<customerId>.*),\soperation\s(?<operation>.*),consumedUnits\s(?<consumedUnits>.*)"
|table customerId operation consumedUnits

 

Sample Search

| makeresults 
| eval event="From abc customerId YETNAKCNK, operation create,consumedUnits 0|From abc customerId YETNAKCNJ, operation update,consumedUnits 2" 
| eval event=split(event,"|") 
| mvexpand event 
| rename event as _raw
| rex field=_raw "customerId (?<customerId>.*),\soperation\s(?<operation>.*),consumedUnits\s(?<consumedUnits>.*)"
|table customerId operation consumedUnits

View solution in original post

0 Karma

bharat149
Explorer

and if i want to apply filter for the customer Id

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

jus add
| where customerId="YETNAKCNK"

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bharat149 

Can you please try this?

YOUR_SEARCH
| rex field=_raw "customerId (?<customerId>.*),\soperation\s(?<operation>.*),consumedUnits\s(?<consumedUnits>.*)"
|table customerId operation consumedUnits

 

Sample Search

| makeresults 
| eval event="From abc customerId YETNAKCNK, operation create,consumedUnits 0|From abc customerId YETNAKCNJ, operation update,consumedUnits 2" 
| eval event=split(event,"|") 
| mvexpand event 
| rename event as _raw
| rex field=_raw "customerId (?<customerId>.*),\soperation\s(?<operation>.*),consumedUnits\s(?<consumedUnits>.*)"
|table customerId operation consumedUnits
0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...