Splunk Search

How can I split similar fields into multiple related events?

pwild_splunk
Splunk Employee
Splunk Employee

I have some events like this. Wifi AP and DEVICE connected to it. A one to many AP to DEVICE relationship exists

AP,DEVICE
---------------
A1,D1
A3,D2
A3,D3
A3,D4
A4,D5
A5,D6
A5,D7

I need to reformat this data to be like this:

tuple,D
-----------
1,A1
1,D1
2,A3
2,D2
3,A3
3,D3
4,A3
4,D4
5,A4
5,D5
6,A5
6,D6
7,A5
7,D7

Is there a cleaner way of doing this than below?

search cmd
| streamstats count as tuple
| eval point="1,2"
| makemv delim="," point
| mvexpand point
| eval D=if(point=1,AD,DEVICE)
|  table  tuple D

This is so I can use the Map+ vis to draw lines between these connected devices.

0 Karma
1 Solution

DalJeanis
Legend

@pwild - you have it exactly right.

You can replace this...

| eval point="1,2"
| makemv delim="," point

...with this...

| eval point=mvrange(1,3)

...but that's about the only change that makes it any more elegant. Everything else you can do is just rearranging furniture.


Oh, wait...

 search cmd
 | streamstats count as tuple
 | eval D=mvappend(AD,DEVICE)
 | mvexpand D
 | table tuple D

Yeah, that's clearly more elegant.

View solution in original post

DalJeanis
Legend

@pwild - you have it exactly right.

You can replace this...

| eval point="1,2"
| makemv delim="," point

...with this...

| eval point=mvrange(1,3)

...but that's about the only change that makes it any more elegant. Everything else you can do is just rearranging furniture.


Oh, wait...

 search cmd
 | streamstats count as tuple
 | eval D=mvappend(AD,DEVICE)
 | mvexpand D
 | table tuple D

Yeah, that's clearly more elegant.

pwild_splunk
Splunk Employee
Splunk Employee

Thanks for such a quick response!

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...