Getting Data In

How to create a table from key value pairs which are not always present?

MarietaO
Engager

Hi everyone,

I would like to extract a table. For instance:

SOH is a special character

Input

id=1, message body= [35=DSOH45=CSOH]

id= 2, message body= [35=FSOH53=ASOH45=CSOH]

+10k messages as such

Result

35  45 53

D    C    

F     C   A

 

Create headers with all keys provided through all messages.

If key is not provided on message then cell should be empty.

As you can see 53 is not always present, when that is the case its cell is empty.

 

Thanks in advance.

 

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

ITWhisperer
SplunkTrust
SplunkTrust
| transpose 0 header_field=key column_name=key
| sort 0 key
| transpose 0 header_field=key column_name=key
| fields - key

View solution in original post

0 Karma

MarietaO
Engager

Works, thanks a lot. And if I want to short by numeric values the columns e.g. asc.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you give an example of what you have and what you would like it to be?

0 Karma

MarietaO
Engager

Sure, thanks a lot.

k1=1, k2=3,body=[8=FIX.4.19=9035=049=INVMGR56=BRKR]

k1=1, k2=3, body=[8=FIX.4.11=1035=049=INVMGR58=BR]

many key value pairs in body (not known).

order is numeric on columns.

To export to csv as a table.

1935495658
 900INVMGRBRKR 
10 0INVMGR BR
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| transpose 0 header_field=key column_name=key
| sort 0 key
| transpose 0 header_field=key column_name=key
| fields - key
0 Karma

MarietaO
Engager

works perfectly thanks.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "35=(?<f35>\w+)SOH"
| rex "45=(?<f45>\w+)SOH"
| rex "53=(?<f53>\w+)SOH"
0 Karma

MarietaO
Engager

e.g. 8=FIX.4.19=9035=049=INVMGR56=BRKR

0 Karma

MarietaO
Engager

The contents of the body field are not indexed. SOH is an invisible character in ASCII.

SOH

The unique keys  are unknown.

Body is indexed but not the key value pairs that I would like to transform to a table.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 "(?<_name>\d+)=(?<_value>\w+)\cA"
| eval namevalue=mvzip(_name, _value)
| mvexpand namevalue
| eval _name=mvindex(split(namevalue,","),0)
| eval _value=mvindex(split(namevalue,","),1)
| eval {_name}=_value
| fields - namevalue
| stats values(*) as * by _raw
0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...