Splunk Search

mvexpand multiple fields

michaelrosello
Path Finder

Is there a way to use mvexpand on multitple values?alt text

This is the result of my current search and I want it to look like this below. Note that there will multiple multivalue fields so i cannot use the mvzip or can I?

SESSIONID    Timstamp    Value1   Value2  Value3 
1             06/21        1         2      3 
1             06/22        2         3      4
Tags (2)

493669
Super Champion

First use mvzip the multi-values into a new field:

 | eval total=mvzip(value1, value2)    // create multi-value field using value1 and value2
 | eval total=mvzip(total, value3)  // add the third field

Now, Expand the field and restore the values:

 | mvexpand total                    // separate multi-value into into separate events
 | makemv total delim=","            // convert the reading into a multi-value
 | eval value1=mvindex(total, 0)      // set value1 to the first value of total
 | eval value2=mvindex(total, 1)      // set value2 to the second value of total
 | eval value3=mvindex(total, -1)     // set value3 to the last value of total

ryhluc01
Communicator

The -1 @ the end is recapturing the second result instead of the last. To fix this just remove the "-" in the last eval.

0 Karma

ryhluc01
Communicator

Can you close out this question by choosing @493669 answer?

0 Karma

madan27
Explorer

Please check this solution: https://answers.splunk.com/answers/724138/

0 Karma

FrankVl
Ultra Champion

To what extend would such an approach risk mixing up the connection between different 'rows' in the multi valued fields? Can you be sure that the first entry in multi valued field1 corresponds with the first entry in multi valued field2?

Might be safer to extract it as 1 field to begin with, then expand and only then split out to the individual fields?

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...