Getting Data In

How to use EVAL in props.conf with a Multivalue field

Rob
Splunk Employee
Splunk Employee

Using props.conf and transforms.conf, I am extracting a multivalue field that contains URL's from my events.

The problem is that when I use an EVAL statement in props.conf to use urldecode to sanitize the some of the URL values in the multivalue field, it will only run on the first field value. For example, the field myURL contains:

  1. http://www.splunk.com
  2. http%3A%2F%2Fwww.splunk.com%2Fdownload%3Fr%3Dheader
  3. http://answers.splunk.com

The props.conf line that is not working is:

EVAL-myURL = urldecode(myURL)

Is there something similar to the mvexpand command that can be run in an eval statement?

1 Solution

Rob
Splunk Employee
Splunk Employee

Unfortunately, a command like mvexpand does not exist for eval. However, to workaround this issue, you can use the eval commands to join the field values together as one value, run the urldecode function, and then split the values back in to a multivalue field. An example for how to do this is:

EVAL-myURL = split(urldecode(mvjoin(myURL, "&")),"&")

Bear in mind that depending on your data, you may need to use a different delimiter to join and split the field. Using the previous example, it might not be desired if your URL contained ampersand characters such as

http://www.splunk.com?answers=1&lang=en

View solution in original post

Rob
Splunk Employee
Splunk Employee

Unfortunately, a command like mvexpand does not exist for eval. However, to workaround this issue, you can use the eval commands to join the field values together as one value, run the urldecode function, and then split the values back in to a multivalue field. An example for how to do this is:

EVAL-myURL = split(urldecode(mvjoin(myURL, "&")),"&")

Bear in mind that depending on your data, you may need to use a different delimiter to join and split the field. Using the previous example, it might not be desired if your URL contained ampersand characters such as

http://www.splunk.com?answers=1&lang=en

yannK
Splunk Employee
Splunk Employee

so much awesomeness !

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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