In Splunk, for any kind of analytics and visualizations, fields play a very important role. Splunk automatically tries to extract and make them available for use for known and properly configured data sources. Since there are a wide variety of sources for data, there could be many fields which do not get automatically extracted. Splunk also provides the Splunk command rex
, which can be used to extract the fields, but this command requires a good understanding of regular expressions to efficiently extract fields from the data. So Splunk provides a very easy to use field extractor to extract fields using an interactive field extractor tool via the Splunk Web interface.
Let us learn to access the field extractor to extract fields from the data, which in turn can be used to create analytics and visualizations in Splunk.
The field extractor can be accessed via the following options:
http://localhost:8000/en-US/app/launcher/field_extractor
Where localhost
and 8000
are to be replaced with, respectively, the IP address and web port of the user's Splunk instance.
The preceding image shows an example to extract the field extractor tool, which can be accessed by taking the following steps:
Now, since we are aware of accessing the field extractor tool, let us see how to extract the fields using this tool. We will learn field extraction using the easiest and most recommended option, which is the third option explained in the Accessing field extractor section.
On clicking Extract fields via the third option, the following interactive screen appears. Even if the first and second options are chosen to access the field extractor, after selecting sourcetype, a screen similar to the following is shown:
The preceding image has the following components:
Let us have a look at field extraction using an example via the Splunk Web console. First we will learn field extraction using the first option as in the preceding image, that is, field extraction using regular expression, and then using the second option, or using delimiters.
Let us have a look at field extraction using regular expression. When regular expression is selected, then a screen similar to the following appears where we can extract the required fields:
The Preview window has the option to select and deselect events to review any event which is wrongly extracted or any event which has a similar regular expression but is not extracted. Various options exist, like previewing matches and non-matches of fields from the data. The event selection sample can also be selected from the Preview window.
The following image shows how we can extract only the IP address of e-mails which are received in the mailbox:
On selecting the Received option as shown in the preceding image, there are two options available. One is to extract similar data patterns in a field and another one is the Require option. It is used to instruct the field extractor tool to extract only those IP addresses (regular expression) where a received value is available. Thus, now the Recievers_IPAddress field will contain only those IP addresses where Received is available in the data.
Similarly, this tool can be used to extract fields based on requirements and can be used to build analytics and visualizations in Splunk.
When the delimiter is chosen while extracting the fields then a screen similar to the following appears:
From the preceding screen, the respective delimiter option, when selected, automatically extracts all the data into fields; as per requirements, the field can be renamed and used. In the preceding example image, it is clearly seen that the data is comma-separated, and hence we will use a comma delimiter to properly extract the fields.
The following image shows the field extraction when the comma delimiter is selected for the preceding example:
Thus, fields can be extracted on the basis of regular expression as well as on the basis of delimiter, as illustrated with the preceding example. Once fields are extracted, click on Next and then Save to make the extracted fields available for analytics and visualization. Permission to save extracted fields for any single app or for all the apps can be configured before saving right from the field extractor tool itself.
18.224.37.68