Splunk® Enterprise

Knowledge Manager Manual

Download manual as PDF

Download topic as PDF

Configure extractions of multivalue fields with fields.conf

Multivalue fields are fields that can appear multiple times in an event and have a different value for each appearance. One of the more common examples of multivalue fields is that of email address fields, which typically appears two to three times in a single sendmail event—once for the sender, another time for the list of recipients, and possibly a third time for the list of Cc addresses, if one exists. If all of these fields are labeled identically (as AddressList, for example), they lose meaning that they might otherwise have if they're identified separately as From, To, and Cc.

Multivalue fields are parsed at search time, which enables you to process the resulting values in the search pipeline. Search commands that work with multivalue fields include makemv, mvcombine, mvexpand, and nomv. For more information on these and other commands see Manipulate and evaluate fields with multiple values in the Search Manual. The complete command reference is in the Search Reference manual.

Use the TOKENIZER setting to define a multivalue field in fields.conf

You can use the TOKENIZER setting to define a multivalue field in fields.conf. At search time, TOKENIZER uses a regular expression to tell the Splunk platform how to recognize and extract multiple field values for a recurring field in an event.

The TOKENIZER setting is used by the where, timeline, and stats commands. It also provides the summary and XML outputs of the asynchronous search API.

Tokenization of indexed fields (fields extracted at index time) is not supported. If you have set INDEXED=true for a field, you cannot also use the TOKENIZER setting for that field. You can use a transform extraction defined in props.conf and transforms.conf to break an indexed field into multiple values.

Prerequisites

Steps

  1. Open the fields.conf file that you want to edit.
    If you have Splunk Enterprise, you edit fields.conf in $SPLUNK_HOME/etc/system/local/, or your own custom app directory in $SPLUNK_HOME/etc/apps/.
  2. Add a stanza for the multivalue field. The stanza name should be the name of the field.
  3. Add a line in the stanza that matches the TOKENIZER setting with a regular expression that is designed to capture multiple values for a field.
  4. (Optional) If you have other attributes to set for the multivalue field, set them in the same stanza underneath the TOKENIZER line.
  5. Save your changes to the file.

TOKENIZER multivalue field configuration syntax

[<field name 1>]
TOKENIZER = <regular expression>

[<field name 2>]
TOKENIZER = <regular expression>
  • <regular expression> should be designed to capture multiple values for a field. For example, if a field name is followed by a list of email addresses, the regular expression should be able to extract each individual address as a separate value of the field without capturing delimiters like commas and spaces.
  • TOKENIZER defaults to empty. When TOKENIZER is empty, the field can only take on a single value.
  • When TOKENIZER is not empty, the first group is taken from each match to form the set of field values.
  • TOKENIZER separates the multiple values of a field with the following delimiter characters: \n.

Example

You start with a poorly formatted email log file where all of the addresses involved are grouped together under AddressList. Here is a sample from that log file.

From:          sender@splunkexample.com
To:            recipient1@splunkexample.com, recipient2@splunkexample.com, recipient3@splunkexample.com
CC:            cc1@splunkexample.com, cc2@splunkexample.com, cc3@splunkexample.com
Subject:       Multivalue fields are out there!
X-Mailer:      Febooti Automation Workshop (Unregistered)
Content-Type:  text/plain; charset=UTF-8
Date:          Wed, 3 Nov 2017 17:13:54 +0200
X-Priority:    3 (normal)

This example from $SPLUNK_HOME/etc/system/README/fields.conf.example breaks email fields To, From, and CC into multiple values.

[To]
TOKENIZER = (\w[\w\.\-]*@[\w\.\-]*\w)

[From]
TOKENIZER = (\w[\w\.\-]*@[\w\.\-]*\w)

[Cc]
TOKENIZER = (\w[\w\.\-]*@[\w\.\-]*\w)

Because the TOKENIZER process adds a \n delimiter between each value it extracts for a field, the multiple values for To in the sample event for this example will display like this: recipient1@splunkexample.com\nrecipient2@splunkexample.com\nrecipient3@splunkexample.com.

PREVIOUS
Example transform field extraction configurations
  NEXT
About calculated fields

This documentation applies to the following versions of Splunk® Enterprise: 7.1.0


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters