Takes a group of events that are identical except for the specified field, which contains a single value, and combines those events into a single event. The specified field becomes a multivalue field that contains all of the single values from the combined events.
There are situations where the
mvjoin eval function is a better option than the
mvcombine command. See Usage.
mvcombine [delim=<string>] <field>
- Syntax: <field>
- Description: The name of a field to merge on, generating a multivalue field.
- Syntax: delim=<string>
- Description: Defines the string to use to generate the combined-string form of the combined single value field. For example, if the values of your field are "1", "2", and "3", and delim is ", " then your combined single value field would be "1, 2, 3".
- Default: a single space, (" ")
mvcombine command accepts a set of input results and finds groups of results where all field values are identical, except the specified field. All of these results are merged into a single result, where the specified field is now a multivalue field.
Because raw events have many fields that vary, this command is most typically useful after paring down the set of available fields with the
fields command. The command is also useful for manipulating the results of certain reporting commands.
mvcombine command creates a multivalue version of the field you specify, as well as a single value version of the field. The multivalue version is displayed be default.
The single value version of the field is a flat string that is separated by a space or by the delimiter that you specify with the
By default the multvalue version of the field is displayed in the results. To display the single value version with the delimiters add the
|nomv command to the end of your search. For example
...| mvcombine delim "," host | nomv host.
Some forms modes of investigating the search results prefer this single value representation, such as exporting to CSV in the UI, or running a command line search with
splunk search "..." -output csv. Some commands that are not
multivalue aware might use this single value as well.
Most ways of accessing the search results prefer the multivalue representation, such as viewing the results in the UI, or exporting to JSON, requesting JSON from the command line search with
splunk search "..." -output json or requesting JSON or XML from the REST API. For these forms of, the selected delim has no effect.
Using mvjoin instead of mvcombine
If the field is a multivalue field and you want a single valued field with a different delimiter, use the
mvjoin evaluation function. For example, a multivalue field contains the values "1","2","3","4","5". You want a single valued field with OR as the delimiter, such as "1 OR 2 OR 3 OR 4 OR 5". Use the
mvjoin function and not the
mvcombine command. See Multivalue Eval Functions.
1. Creating a multivalue field
|This example uses the sample dataset from the Search Tutorial. To try this example yourself, download the data set from Get the tutorial data into Splunk and follow the instructions in the Search Tutorial to upload the data.|
To understand how mvcombine works, let's explore the data.
- Set the time range to All time.
- Run the following search.
index=* | stats max(bytes) AS max, min(bytes) AS min BY host
The results show that the max and min fields have duplicate entries for the hosts that start with
www. The other hosts show no results for the max and min fields.
- To remove the other hosts from your results, modify the search to add
host=www*to the search criteria.
index=* host=www* | stats max(bytes) AS max, min(bytes) AS min BY host
Because the values in the
mincolumns contain the exact same values, you can use the
mvcombineto combine the host values into a multivalue result.
| mvcombine hostto your search and run the search again.
index=* host=www* | stats max(bytes) AS max, min(bytes) AS min BY host | mvcombine host
Instead of three rows, one row is returned. The host field is now a multvalue field.
2. Returning the delimited values
As mentioned in the Usage section, by default the delimited version of the results are not returned in the output. To return the results with the delimiters, you must return the single value string version of the field.
nomv command to your search. For example:
index=* host=www* | stats max(bytes) AS max, min(bytes) AS min BY host | mvcombine delim="," host | nomv host
To return the results with a space after each comma, specify
In multivalue events:
sourcetype="WMI:WinEventLog:Security" | fields EventCode, Category,RecordNumber | mvcombine delim="," RecordNumber | nomv RecordNumber
Combine the values of "foo" with a colon delimiter.
... | mvcombine delim=":" foo
Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the mvcombine command.
This documentation applies to the following versions of Splunk® Enterprise: 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.0.9, 6.0.10, 6.0.11, 6.0.12, 6.0.13, 6.0.14, 6.0.15, 6.1, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 6.1.6, 6.1.7, 6.1.8, 6.1.9, 6.1.10, 6.1.11, 6.1.12, 6.1.13, 6.1.14, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.2.4, 6.2.5, 6.2.6, 6.2.7, 6.2.8, 6.2.9, 6.2.10, 6.2.11, 6.2.12, 6.2.13, 6.2.14, 6.2.15, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.4, 6.3.5, 6.3.6, 6.3.7, 6.3.8, 6.3.9, 6.3.10, 6.3.11, 6.3.12, 6.3.13, 6.3.14, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.4.10, 6.4.11, 6.5.0, 6.5.1, 6.5.1612 (Splunk Cloud only), 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.7, 6.5.8, 6.5.9, 6.5.10