Splunk Search

Why is mvexpand not extracting all key/value pairs?

jmartens
Path Finder

I am trying to expand multiple fields from specific log lines using mvexpand but for some strange reason some fields are not extracted as expected, see screenshot for an example:

jmartens_0-1678980355806.png

I would also like to have the key/value pairs for col and gantry.

 

Labels (1)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The max_match option is relevant because its absence tells me we're not dealing with a mutli-value field and so the mvexpand command is not of use.

To get each component of the values field into its own field we need to parse it.  There is the extract command, but it only works with _raw so we have to jump through some hoops to use it.

<<your search to extract the values field>>
| eval _raw = values
| extract pairdelim=, kvdelim==
| table values count max min avg col gantry energy

 

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

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This is not an mvexpand problem because the values field is not a multi-value field.  We know it can't be a multi-value field because the rex command does not use the max_match option, which means only the first match of the regex will be extracted.

The fields that were extracted probably are the result of automatic extraction because they're in key=value format.  I can't explain why the col and gantry fields were not extracted.

What is the end goal of this query?  The mvexpand command puts each value of a multi-value field into a new event - is that what is desired?

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

jmartens
Path Finder

@richgalloway wrote:

We know it can't be a multi-value field because the rex command does not use the max_match option, which means only the first match of the regex will be extracted.

I don't see why the regex here is such a proof. The `rex` is used to extract two named fields, of which the latter contains the values I am after and is assigned to values. I see no reason why `max_match` is even relevant here.


@richgalloway wrote:

What is the end goal of this query?  The mvexpand command puts each value of a multi-value field into a new event - is that what is desired?


The end goal is to extract all values (as per column headings from the results in my screenshot) from value field extracted using the regular expression and assigning them to the event so I can process and plot these values.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The max_match option is relevant because its absence tells me we're not dealing with a mutli-value field and so the mvexpand command is not of use.

To get each component of the values field into its own field we need to parse it.  There is the extract command, but it only works with _raw so we have to jump through some hoops to use it.

<<your search to extract the values field>>
| eval _raw = values
| extract pairdelim=, kvdelim==
| table values count max min avg col gantry energy

 

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

jmartens
Path Finder

I had indeed resolved it using in the mean time: 

| extract pairdelim="," kvdelim="=" clean_keys=t

 

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...