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!

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...

Logs to Metrics

Logs and Metrics Logs are generally unstructured text or structured events emitted by applications and written ...

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...