Splunk Search

How to Split rows into columns

vik
Explorer

I am trying to split the values in both the columns and create 5 rows by assigning respective values. I need an output as below. Can someone suggest how can I achieve this ? 

I tried mvexpand but it does not seem to help. Anything else we can try ? 

 

field1       | field 2 

-------------------------------

Name 1   |  10

-------------------------------

Name 2   | 12

 

Screen Shot 2023-03-09 at 5.14.59 PM.png

Labels (2)
0 Karma
1 Solution

Tom_Lundie
Contributor

How about something like this?

| eval tmp_field = mvzip(field1, field2, "-|-")
| fields - field1, field2
| mvexpand tmp_field
| makemv delim="-|-" tmp_field
| eval field1 = mvindex(tmp_field, 0)
| eval field2 = mvindex(tmp_field, 1)
| fields - tmp_field

 

View solution in original post

0 Karma

Tom_Lundie
Contributor

How about something like this?

| eval tmp_field = mvzip(field1, field2, "-|-")
| fields - field1, field2
| mvexpand tmp_field
| makemv delim="-|-" tmp_field
| eval field1 = mvindex(tmp_field, 0)
| eval field2 = mvindex(tmp_field, 1)
| fields - tmp_field

 

0 Karma

vik
Explorer

Thanks a lot! 

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Part 2: Diving Deeper With AIOps

Getting the Most Out of Event Correlation and Alert Storm Detection in Splunk IT Service Intelligence   Watch ...

User Groups | Upcoming Events!

If by chance you weren't already aware, the Splunk Community is host to numerous User Groups, organized ...

Splunk Lantern | Spotlight on Security: Adoption Motions, War Stories, and More

Splunk Lantern is a customer success center that provides advice from Splunk experts on valuable data ...