Splunk Search

How to split single multivalue event into multiple multivalue events?

ERFFFFF
Explorer

Hello everyone !

I'm trying to split a single multivalue event into multiple multivalue events.

Here is my base search :

sourcetype="xxxx"
| transaction clientip source id maxspan=5m startswith="yesorno=yes" endswith="event=connected" keepevicted=true mvlist=true,responsetime,status,yesorno,clientip,event,_time
| sort _time
| eval MergedColumns=responsetime . " " . yesorno
| stats list(event) as event, list(MergedColumns) as MergedColumns, list(responsetime) as responsetime, by yesorno, clientip, id
| where !(event=="connected")
| table MergedColumns source clientip

Unfortunately, i am obliged to use a transaction here and not the stats command.

Here is my data :

MergedColumns source clientip
10 yes
510 no
348 no
50886 no
username1
xxx.xxx.xxx.xxx
10 yes
513 no
1239 no
9 yes
160 no
340 no
21421 no
509 no
685 no
13799 no
149 no
username2 xxx.xxx.xxx.xxx


I would like to split my event on the "xxx yes" like so :

MergedColumns source clientip
10 yes
510 no
348 no
50886 no
username1
xxx.xxx.xxx.xxx
10 yes
513 no
1239 no
username2
xxx.xxx.xxx.xxx
9 yes
160 no
340 no
21421 no
509 no
685 no
13799 no
149 no
username2
xxx.xxx.xxx.xxx


Moreover, here, i have only two "xxx yes" in the same multivalue event, but i can possibly have more than that (like 3 or 4).
I tried lots of things but none seems to work...
(here is the regex to extract "xxx yes" => "^\S{1,} yes$")

In fact, adding this :

| mvexpand MergedColumns
| regex MergedColumns="^\S{1,} success"
| table MergedColumns source clientip

This above seems to split my values correctly, however, it removes all the remaining "xxx no" values.

Does anyone have a solution ?

Kind regards,

Labels (5)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

sourcetype="xxxx"
| transaction clientip source id maxspan=5m startswith="yesorno=yes" 
endswith="event=connected" keepevicted=true mvlist=true,responsetime,status,yesorno,clientip,event,_time
| sort _time
| eval MergedColumns=responsetime . " " . yesorno
| stats list(event) as event, list(MergedColumns) as MergedColumns, 
list(responsetime) as responsetime by yesorno, clientip, id
| where !(event=="connected")
| table MergedColumns source clientip
| mvexpand MergedColumns
| eval temp=if(match(MergedColumns,".+yes$"),1,0)
| accum temp
| stats list(MergedColumns) as MergedColumns by source clientip temp | fields - temp

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Curious to know how tightly your hand is tied behind your back! Why are you obliged to use transaction and not stats?

0 Karma

ERFFFFF
Explorer

because i track which user is trying to connect (starting with the event "yesorno=yes" and terminate with the "event=connected") (if i'am in the wrong, please correct me, i'am still learning)

0 Karma

somesoni2
Revered Legend

Give this a try

sourcetype="xxxx"
| transaction clientip source id maxspan=5m startswith="yesorno=yes" 
endswith="event=connected" keepevicted=true mvlist=true,responsetime,status,yesorno,clientip,event,_time
| sort _time
| eval MergedColumns=responsetime . " " . yesorno
| stats list(event) as event, list(MergedColumns) as MergedColumns, 
list(responsetime) as responsetime by yesorno, clientip, id
| where !(event=="connected")
| table MergedColumns source clientip
| mvexpand MergedColumns
| eval temp=if(match(MergedColumns,".+yes$"),1,0)
| accum temp
| stats list(MergedColumns) as MergedColumns by source clientip temp | fields - temp

ERFFFFF
Explorer

Thank you very much, it works like a charm ! 😄

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...