Admin Manual

 


Set up custom (scripted) inputs

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.

Set up custom (scripted) inputs

Splunk can accept events from scripts that you provide. Scripted input is useful in conjunction with command-line tools, such as vmstat, iostat, netstat, top, etc. You can use scripted input to get data from APIs and other remote data interfaces and message queues. You can then use that data to generate metrics and status data through commands like vmstat, iostat, etc.

Lots of apps on Splunkbase provide scripted inputs for specific applications. -- You can find them on the Browse more apps tab in the Launcher.

You configure custom scripted inputs from Splunk Manager or by editing inputs.conf.

Note: On Windows platforms, you can enable text-based scripts, such those in perl and python, with an intermediary Windows batch (.bat) file.

Caution: Scripts launched through scripted input inherit Splunk's environment, so be sure to clear environment variables that can affect your script's operation. The only environment variable that's likely to cause problems is the library path (most commonly known as LD_LIBRARY_PATH on linux/solaris/freebsd).

Add a scripted input in Splunk Web

To add a scripted input in Splunk Web:

1. Click Manager in the upper right-hand corner of Splunk Web.

2. Under System configurations, click Data Inputs.

3. Click Scripts.

4. Click Add new to add an input.

5. In the Command text box, specify the script command, including the path to the script.

6. In Interval, specify the interval in seconds between script runtimes. The default is 60 (seconds).

7. Enter a new Source name to override the default source value, if necessary.

Important: Consult Splunk support before changing this value.

8. Change the Host value, if necessary.

9. Set the Source type.

Source type is a default field added to events. Source type is used to determine processing characteristics such as timestamps and event boundaries. Choose:

10. Set the Index. Leave the value as "default" unless you have defined multiple indexes to handle different types of events. In addition to indexes meant for user data, Splunk has a number of utility indexes, which show up in the dropdown box.

11. Click Save.

Add a scripted input via inputs.conf

Configure inputs.conf using the following attributes:

[script://$SCRIPT] 
interval = <integer>|<cron schedule>
index = <index>
sourcetype = <iostat, vmstat, etc>  OPTIONAL
source = <iostat, vmstat, etc> OPTIONAL
disabled = <true | false>

If you want the script to run continuously, write the script to never exit and set it on a short interval. This helps to ensure that if there is a problem the script gets restarted. Splunk keeps track of scripts it has spawned and will shut them down upon exit.

Example using inputs.conf

This example shows the use of the UNIX top command as a data input source.

$ mkdir $SPLUNK_HOME/etc/apps/scripts
$ #!/bin/sh
 top -bn 1  # linux only - different OSes have different paramaters
chmod +x $SPLUNK_HOME/etc/apps/scripts/bin/top.sh
$SPLUNK_HOME/etc/apps/scripts/bin/top.sh
[script:///opt/splunk/etc/apps/scripts/bin/top.sh]
interval = 5                # run every 5 seconds
sourcetype = top        # set sourcetype to top
source = script://./bin/top.sh   # set source to name of script

props.conf

You may need to modify props.conf:

For example, adding the following to $SPLUNK_HOME/etc/apps/scripts/default/props.conf forces all lines into a single event:

[top]
BREAK_ONLY_BEFORE = <stuff>

Since there is no timestamp in the top output we need to tell Splunk to use the current time. This is done in props.conf by setting:

DATETIME_CONFIG = CURRENT

This documentation applies to the following versions of Splunk: 4.1 , 4.1.1 , 4.1.2 , 4.1.3 , 4.1.4 , 4.1.5 , 4.1.6 , 4.1.7 , 4.1.8 View the Article History for its revisions.


Comments

I tested this in Splunk Web. That field appears to accept absolute paths without problem, at least on my Splunk installation. If you're still experiencing problems, you might want to describe the issue in greater detail in Splunk Answers: http://splunk-base.splunk.com/answers/

Sgoodman
July 25, 2011

The help text underneath Source Command isn't very useful.
On Unix: /opt/splunk/bin/scripts/getData.sh foo "bar baz"

Actually it won't accept absolute paths starting / and will only accept a path relative to $SPLUNK_HOME

Shermozle
July 24, 2011

Can you add some sample config to start with?

Dannytrinh
August 19, 2010

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

Was this documentation topic helpful?

If you'd like to hear back from us, please provide your email address:

We'd love to hear what you think about this topic or the documentation as a whole. Feedback you enter here will be delivered to the documentation team.

Feedback submitted, thanks!