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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

How much can you really learn in 3 minutes?

Observability can certainly be hard to understand – there's a lot of jargon and buzzwords and it seems to ...

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...