Monitor network ports
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Contents
Monitor network ports
You can enable Splunk to accept an input on any TCP or UDP port. Splunk consumes any data sent on these ports. Use this method for syslog (default port is UDP 514) or set up netcat and bind to a port.
Note: UDP input will append a timestamp and host to received events.
TCP is the protocol underlying Splunk's data distribution, which is the recommended method for sending data from any remote machine to your Splunk server. Note that the user you run Splunk as must have access to the port. On a Unix system you must run as root to access a port under 1024.
Add a network input using Splunk Web
Add inputs from network ports via Splunk Web.
1. Click Manager in the upper right-hand corner of Splunk Web.
2. Under System configurations click Data inputs.
3. Pick TCP or UDP.
4. Click New to add an input.
5. Enter a port number.
6. If this is a TCP input, you can specify whether this port should accept connections from all hosts or one host. If you specify one host, enter the IP address of the host.
7. Now 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:
- From List
- Select one of the predefined source types from the drop-down list.
- Manual
- Label your own source type in the text box.
8. After specifying the source, host, and source type, click Submit.
Add a network input using the CLI
Monitor files and directories via Splunk's Command Line Interface (CLI). To use Splunk's CLI, navigate to the $SPLUNK_HOME/bin/ directory and use the ./splunk command.
If you get stuck, Splunk's CLI has built-in help. Access the main CLI help by typing splunk help. Individual commands have their own help pages as well -- type splunk help <command>.
The following commands are available for input configuration via the CLI:
| Command | Command syntax | Action |
|---|---|---|
| add | add tcp | udp $SOURCE [-parameter value] ...
| Add inputs from $SOURCE. |
| edit | edit tcp | udp $SOURCE [-parameter value] ...
| Edit a previously added input for $SOURCE. |
| remove | remove tcp | udp $SOURCE
| Remove a previously added data input. |
| list | list tcp | udp
| List the currently configured monitor. |
Change the configuration of each data input type by setting additional parameters. Parameters are set via the syntax: -parameter value.
| Parameter | Required? | Description |
|---|---|---|
| $SOURCE | Require | Port number to listen for data to index. |
| sourcetype | Optional | Specify a sourcetype field value for events from the input source. |
| index | Optional | Specify the destination index for events from the input source. |
| hostname | Optional | Specify a host name to set as the host field value for events from the input source. |
| remotehost | Optional | Specify an IP address to exclusively accept data from. |
| resolvehost | Optional | Set True of False (T | F). Default is False. Set True to use DNS to set the host field value for events from the input source. |
Example
Configure a network input, then set the sourcetype:
- Configure a UDP input to watch port 514 and set the sourcetype to "syslog".
Check the Best Practices Wiki for information about the best practices for using UDP when configuring Syslog input.
./splunk add udp 514 -sourcetype syslog
- Set the UDP input's host value via DNS. Use
authwith your username and password.
./splunk edit udp 514 -resolvehost true -auth admin:changeme
Note: Splunk must be running as root to watch ports under 1024.
Note: Inputs added via CLI will be in etc/apps/search/local/inputs.conf.
Add a network input using inputs.conf
To add an input, add a stanza for it to inputs.conf in $SPLUNK_HOME/etc/system/local/, or your own custom application directory in $SPLUNK_HOME/etc/apps/. If you have not worked with Splunk's configuration files before, read about configuration files in this manual before you begin.
You can set any number of attributes and values following an input type. If you do not specify a value for one or more attributes, Splunk uses the defaults that are preset in $SPLUNK_HOME/etc/system/default/ (noted below).
TCP
[tcp://<remote server>:<port>] <attrbute1> = <val1> <attrbute2> = <val2> ...
This type of input stanza tells Splunk to listen to <remote server> on <port>. If <remote server> is blank, Splunk listens to all connections on the specified port.
host = <string>
- Set the host value of your input to a static value.
-
host::is automatically prepended to the value when this shortcut is used. - Defaults to the IP address of fully qualified domain name of the host where the data originated.
index = <string>
- Set the index where events from this input will be stored.
-
index::is automatically prepended to the value when this shortcut is used. - Defaults to
main(or whatever you have set as your default index). - For more information about the index field, see "How indexing works" in this manual.
sourcetype = <string>
- Set the sourcetype name of events from this input.
-
sourcetype::is automatically prepended to the value when this shortcut is used. - Splunk automatically picks a source type based on various aspects of your data. There is no hard-coded default.
- For more information about the sourcetype field, read about source types in the Knowledge Manager Manual.
source = <string>
- Set the source name of events from this input.
- Defaults to the file path.
-
source::is automatically prepended to the value when this shortcut is used.
queue = <string> (parsingQueue, indexQueue, etc)
- Specify where the input processor should deposit the events that it reads.
- Can be any valid, existing queue in the pipeline.
- Defaults to
parsingQueue.
connection_host = [ip | dns]
- If set to ip: the TCP input processor rewrites the host with the ip address of the remote server.
- If set to dns: the host is rewritten with the DNS entry of the remote server.
- Defaults to ip.
UDP
[udp://<port>] <attrbute1> = <val1> <attrbute2> = <val2> ...
This type of input stanza is similar to the TCP type, except that it listens on a UDP port.
host = <string>
- Set the host value of your input to a static value.
-
host=is automatically prepended to the value when this shortcut is used. - Defaults to the IP address of fully qualified domain name of the host where the data originated.
index = <string>
- Set the index where events from this input will be stored.
-
index=is automatically prepended to the value when this shortcut is used. - Defaults to
main(or whatever you have set as your default index). - For more information about the index field, read about how indexing works in this manual.
sourcetype = <string>
- Set the sourcetype name of events from this input.
-
sourcetype=is automatically prepended to the value when this shortcut is used. - Splunk automatically picks a source type based on various aspects of your data. There is no hard-coded default.
- For more information about the sourcetype field, read about source types in the Knowledge Manager Manual.
source = <string>
- Set the source name of events from this input.
- Defaults to the file path.
-
source=is automatically prepended to the value when this shortcut is used.
queue = <string> (parsingQueue, indexQueue, etc)
- Specify where the input processor should deposit the events that it reads.
- Can be any valid, existing queue in the pipeline.
- Defaults to
parsingQueue.
_rcvbuf = <int>
- Specify the receive buffer for the UDP port, measured in bytes.
- If the value is 0 or negative, it is ignored.
- The default value for Splunk is 1MB (the default in the OS varies).
no_priority_stripping = true | false
- If this attribute is set to true, then Splunk does NOT strip the <priority> syslog field from received events.
- Otherwise, Splunk strips syslog priority from events.
no_appending_timestamp = true
- If this attribute is set to true, then Splunk does NOT append a timestamp and host to received events.
- Note: Do NOT include this key at all if you want to append timestamp and host to received events.
This documentation applies to the following versions of Splunk: 4.0 , 4.0.1 , 4.0.2 , 4.0.3 , 4.0.4 , 4.0.5 , 4.0.6 , 4.0.7 , 4.0.8 , 4.0.9 , 4.0.10 , 4.0.11 View the Article History for its revisions.