Splunk® Enterprise

User Manual

Download manual as PDF

Splunk version 4.x reached its End of Life on October 1, 2013. Please see the migration information.
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Download topic as PDF

Add data to Splunk

This topic assumes that you have already downloaded, installed, and started a Splunk server. If you haven't yet, go back to the previous topic for instructions to do that.

Once you've started and logged into Splunk, you need to give it data that you can search. This topic walks you through downloading the sample dataset and adding it into Splunk.

Download the sample data file

This tutorial uses sample data from an fictitious online store, the Flower & Gift shop, to teach you about using Splunk. The sample data includes:

  • Apache web server logs
  • mySQL database logs

You can feed Splunk data from files and directories, network ports, and custom scripts, but for this tutorial, you will upload a compressed file directly to Splunk. Also, this tutorial is designed to be completed in a matter of hours. But, if you want to spread it out over a few days, just download a new sample data file and add it!

To proceed with this tutorial, download (but do not uncompress) the sample data from here: sampledata.zip This sample data file is updated daily.

Get the sample data into Splunk

Logging into Splunk should have taken you to Splunk Home. If it isn't the first view that you see, use the App list to select Home.

App menu home4.3.png

1. In Splunk Home, click Add data.

This takes you to the Add Data to Splunk dialogue where you can Choose a Data Type to add Or Choose a Data Source.

2. Under Or Choose a Data Source, click From files and directories.

Add data from files.4.3.png

This takes you to the Preview data dialogue, which enables you to see a preview of the data before you add it to a Splunk index. For the purposes of this tutorial, you won't need to do this. If you're interested in reading more about data preview, refer to "Overview of data preview" in the Getting Data In manual.

3. Select Skip preview and click Continue.

Skip preview4.3.png

This takes you to the Home > Add data > Files & directories > Add new view. This is where you will upload the sample data file. Normally, this is all you need to do and Splunk handles the rest without any changes needed. For the purposes of this tutorial, however, you will also edit some of the properties.

4. Under Source, select Upload and index a file and browse for the sample data file that you just downloaded.

The source of an event tells you where it came from. If you collect data from files and directories, the "source" is the full pathname of the file or directory. In the case of a network-based source, the source is the protocol and port, such as UDP:514.


5. Select More settings.

This enables you to override Splunk's default settings for Host, Source type, and Index. For this tutorial, you're just going to change the Host settings.

What about the Source type and Index settings?

The source type of an event tells you what kind of data it is, usually based on how it's formatted. Examples of source types are access_combined or cisco_syslog. This classification lets you search for the same type of data across multiple sources and hosts. For more information about how Splunk source types your data, read "Why source types matter" in the Getting Data In manual.

The index setting tells Splunk where to put the data. By default, it's stored in main, but you might want to consider partitioning your data into different indexes if you have many types. For more information about creating custom indexes, read "Set up multiple indexes" in the Admin manual.

6. Under Host and Set host, choose regex on path.

An event's host value is typically the hostname, IP address, or fully qualified domain name of the network host from which the event originated. If you take a look at the Sampledata.zip file, it contains four directories (folders): three of the folders are named for Apache web servers and one is a MySQL server. You want to set the host value to the names of these folders.

By selecting regex on path, you're telling Splunk to use a regular expression (regex) to match the segment of the path within the compressed file that you want to set as your host value.

Custom host4.2.png

7. Under Regular expression, copy and paste:

For Linux\Unix:


For Windows:


This regex should match any characters in the segment path under (Linux/Unix) Sampledata.zip/ or (Windows) Sampledata.zip\ .

8. Click Save.

When it's finished, Splunk displays a message saying the upload was successful.

Add data success4.3.png

Click Start searching and proceed to the next topic in this tutorial to look at your data in the Search app.

More about getting data in

This topic only discusses one type of input, uploading a local file, which is all you need to run through the tutorial. For information about all other type of data inputs Splunk can handle and how to add them, refer to the Getting Data In manual beginning with the topic, "What Splunk can index".

Start Splunk
The Search app

This documentation applies to the following versions of Splunk® Enterprise: 4.3, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.3.6, 4.3.7


*Sigh*, still wrong. I cannot write a pair of angle brackets in these comments...

October 23, 2012

Sorry, IE + Win7 mangled the regex test program. The while loop line should be:<br /><br />while ( ) {<br /><br />and the matched line should be:<br /><br />print "Matched: |$`$'|\n";

October 23, 2012

I have a nodding acquaintance with Regular Expressions from dabbling with Perl programs in a Unix environment, but the Unix/Linux Regex above:<br /><br />./([^/]+)/<br /><br />Makes no sense to me. It also throws syntax errors when I plug in into this little Regex test perl program:<br /><br />=====<br />#!/usr/bin/perl<br />while () { # take one input line at a time<br /> chomp;<br /> if (/YOUR_PATTERN_GOES_HERE/) {<br /> print "Matched: |$`$'|\n"; # the special match vars<br /> } else {<br /> print "No match: |$_|\n";<br /> }<br />}<br />=====<br /><br />Is there some additional syntax specific to Splunk in this Regex? Or is it a different flavor of Regex than Perl Regex?

October 22, 2012

Sorry for the delayed response, we have updated the topic.

Cgales splunk, Splunker
August 20, 2012

+1 - had to use Rich's regex, too

August 8, 2012

Can confirm that Richprescotts example is working, the one originally provided in the tutorial not.<br />Please be so kind to rework this article.

July 30, 2012

Yes, that's correct! Richprescott's regular expression is the one which works on Windows.<br /><br />The one specified in the tutorial (for Windows) only extracts a single log file.<br /><br />~ rajeev.joshi13@gmail.com

Rajeev joshi13
June 11, 2012

The regex listed did not work when importing the data from a Windows machine. Had to use the following regex instead: Sampledata.zip:.\\([^/]+)/

February 10, 2012

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