Splunk Search

Combine separate fields to a single MV field?

pbarbuto
Path Finder

As far as I know using mvcommand only creates an MV field out of values from a single field. In a column for example. I need to combine several fields to a single MV_field but all these fields have different names. 

For example, I have field1, field2, field3. And I need a single MV_field containing values for all of them. Also, it would nice if this could be dynamic in a way that I can combine 'field*' to 'MV_field' with all the values.

I am able to accomplish combining the different fields using evals mvappend function, but it doesn't take wildcards.  

Example, "| eval MV_field=mvappend(field1,field2,field3)" works. But there isn't always the same amount of fields. 

It would be really nice to be able to do "| eval MV_field=mvappend(field*)" to simply catch all that exist and throw them in a single MV_field.

Is this possible?

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I believe mvappend is the right command.  You just need a way to apply to a variable number of fields.  Try the foreach command for that.

| eval MV_field = ""
| foreach field* [ eval MV_field = mvappend(MV_field, <<FIELD>>) ]

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

pbarbuto
Path Finder

yup that'll do it. Thanks! 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I believe mvappend is the right command.  You just need a way to apply to a variable number of fields.  Try the foreach command for that.

| eval MV_field = ""
| foreach field* [ eval MV_field = mvappend(MV_field, <<FIELD>>) ]

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...