
The mvindex function takes two or three arguments and returns a subset of the multivalue field using the index values provided. Alternatively, splits field by using a regex. The delimiter can be a multicharacter delimiter. Using makemv command, we can converts a single valued field into a multivalue field by splitting the values on a simple string delimiter. For each result, the mvexpand command creates a new result for every multivalue field. In this blog we are going to explore spath command in splunk. Using mvexpand command, we can expands the values of a multivalue field into separate events, one event for each value in the multivalue field. To enable syntax highlighting just drop the first file splunk. Mvzip is mv eval function command, which combines 2 fields values to one field.

Let’s combine all the fields values to one field value using mvzip command. We could see that, key_a field is under an array named as key_4. From above json sample data, we need to extract the key_a field. If we need to extract the specific field from array in json, we can mention the path, so that splunk can understand the key-value pair needed to be extracted. The spath command will extract the all fields automatically. If we run spath command to above sample json data, key-value pairs will extracted automatically.

The supported arguments are INPUT, PATH, OUTPUT. The spath command is used to extract the fields from structured data format like json, xml etc. The fields created by spath are mostly multivalued fields, specially the fields extracted out of array. So the key_4 will points to the array elements following curly bracket Because the key_4, values showing as an array, which is in square brackets. Key_1, key_2, key_3 will be considered as fields, but key_4 won’t. Let’s understand, how splunk spath command will extract the fields from above json data.įrom above data, when we executed spath command, the first curly bracket is consider as opening and then the following key-value pairs will extracted directly. spath command will breakdown the array take the key as fields.

We can use spath splunk command for search time fields extraction. JSON is structured data format with key-value pair rendered in curly brackets.
