Splunk Cloud

Getting Data In

Download manual as PDF

Download topic as PDF

Get data from TCP and UDP ports on a forwarder for Splunk Cloud

You can configure a Splunk forwarder to accept an input on any TCP or UDP port. You can use this method to capture data from network services such as syslog (default port is UDP 514). You can also set up the netcat service and bind it to a port.

Before you configure a network input

Read the following sections before you configure a network input.

Consider ingesting the data by monitoring a file instead

The best practice for collecting network data is to write it to a file and then monitor that file. A file monitor input is most reliable in case your server goes down, and it also allows you to add the data again if you have to clean your index for some reason. For more information about monitoring files, see Monitor files and directories on a forwarder for Splunk Cloud.

If you must ingest network inputs directly, use TCP

TCP is the network protocol that underlies the Splunk platform data distribution scheme. It is the recommended protocol for sending data from any remote host to your Splunk forwarder. The Splunk platform can index remote data from syslog-ng or any other application that transmits via TCP.

Splunk forwarders support monitoring over UDP, but you should use TCP to send network data instead whenever possible. UDP is not desirable as a transport because, among other reasons, it does not guarantee delivery of network packets. See Working with UDP connections on the Splunk Community Wiki for recommendations if you must send network data with UDP.

When you monitor TCP network ports, the user the forwarder runs as must have access to the port you want to monitor. On many Unix operating systems, by default, you must run the forwarder as the root user to listen directly on a port below 1024.

Work around line merging of UDP packets

Splunk software does not index each UDP packet as an independent event. Instead, it performs event merging on the data stream and merges events together if they don't have a clear timestamp.

You can avoid this problem by editing the underlying source type in props.conf and setting the SHOULD_LINEMERGE attribute to false. This keeps Splunk software from merging packets together.

Confirm how your network device handles external monitoring before you use the network monitoring input

Before you begin monitoring the output of a network device with a forwarder, confirm how the device interacts with external network monitors.

If you configure TCP logging on some network devices, such as a Cisco Adaptive Security Appliance (ASA), and the device cannot connect to the monitor, it might cause reduced performance or stop logging, or worse. By default, the Cisco ASA stops accepting incoming network connections when it encounters network congestion or connectivity problems.

Add a network input

There are three ways to add a network input on a forwarder:

Add a network input using Splunk Web

If you are using a heavy forwarder, you can add inputs from network ports using Splunk Web.

  1. Click Settings.
  2. Click Data Inputs.
  3. Choose TCP or UDP.
  4. Click New to add an input.
  5. In the left pane, click TCP / UDP to add an input.
  6. Click the TCP or UDP button to choose between a TCP or UDP input.
  7. In the Port field, enter a port number.
  8. In most cases, leave the Source name override field blank. If necessary, you can enter a new source name to override the default source value.
  9. If this is a TCP input, specify whether this port should accept connections from all hosts or only one host in the Only accept connections from field. If you only want the input to accept connections from one host, enter the host name or IP address of the host. You can use wildcards to specify hosts.
  10. Click Next to continue to the Input Settings page.
  11. Set the Source type. This is a default field that Splunk software adds to events and uses to determine processing characteristics, such as timestamps and event boundaries.
  12. Set the Host name value. You have several choices:
    • IP. Sets the input processor to rewrite the host with the IP address of the remote server.
    • DNS. Sets the host to the DNS entry of the remote server.
    • Custom. Sets the host to a user-defined label.

    Learn more about setting the host value in About hosts.

    Host only sets the host field in the resulting events. It does not direct the forwarder to look on a specific host on your network.

  13. Set the Index that Splunk software should send data to for this input. Leave the value as "default" unless you have defined multiple indexes to handle different types of events. In addition to indexes for user data, Splunk Enterprise has a number of utility indexes, which also appear in this dropdown box.
  14. Click Review.
  15. If you need to adjust any settings, click < to go back to the previous step in the wizard. Otherwise, click Submit.

The forwarder then loads the "Success" page and begins indexing the specified network input.

Add a network input using the CLI

To access the CLI on your forwarder, navigate to the $SPLUNK_HOME/bin/ directory and use the ./splunk command.

If you get stuck, the CLI has help. Access the main CLI help by typing splunk help. Individual commands have their own help pages as well and can be accessed by typing splunk help <command>.

The following CLI commands are available for network input configuration:

Command Command syntax Action
add add tcp|udp <port> [-parameter value] ... Add inputs from <port>.
edit edit tcp|udp <port> [-parameter value] ... Edit a previously added input for <port>.
remove remove tcp|udp <port> Remove a previously added data input.
list list tcp|udp [<port>] List the currently configured monitor.

The <port> is the port number on which to listen for data. The user you run the Splunk forwarder as must have access to this port.

You can modify the configuration of each input by setting any of these additional parameters:

Parameter Required? Description
sourcetype No Specify a sourcetype field value for events from the input source.
index No Specify the destination index for events from the input source.
hostname No Specify a host name to set as the host field value for events from the input source.
remotehost No Specify an IP address to exclusively accept data from.
resolvehost No Set to true or false (T | F). Default is False. Set to true to use DNS to set the host field value for events from the input source.
restrictToHost No Specify a host name or IP address that this input should accept connections from only.

If you decide to only accept connections from a specific host when you create a TCP input, once you save that input, you can neither change nor remove that host later. To change or remove the restricted host of a port, first delete the input that contains the old restricted host. Then, add a new input that either contains the new restricted host or has no restriction.

For example, to configure a UDP input to watch port 514 and set the source type to "syslog":

     ./splunk add udp 514 -sourcetype syslog

For example, to set the UDP input host value via DNS, use auth with your username and password:

     ./splunk edit udp 514 -resolvehost true -auth admin:changeme

For information on best practices for using UDP, see Best practices for configuring Syslog input in the Community Wiki.

Add a network input using inputs.conf

To add an input, add a stanza for it to inputs.conf on your forwarder in $SPLUNK_HOME/etc/system/local/, or your own custom application directory in $SPLUNK_HOME/etc/apps/. If you have not worked with Splunk platform configuration files before, read About configuration files in the Splunk Enterprise Admin 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, the forwarder uses the defaults that are preset in $SPLUNK_HOME/etc/system/default/ (noted below).

The following TCP input stanza tells the forwarder to listen to <remote server> on <port>. If <remote server> is blank, the forwarder listens to all connections on the specified port.

[tcp://<remote server>:<port>]
<attrbute1> = <val1>
<attrbute2> = <val2>
...

Use the following stanza type if you receive encrypted, unparsed data from a forwarder or third-party system. Set <port> to the port on which the forwarder or third-party system is sending unparsed, encrypted data.

[tcp-ssl:<port>]

The TCP input stanza supports the following attributes.

Attribute Description Default
host = <string> Sets the host key/field to a static value for this stanza. Also sets the host key initial value. The forwarder uses the key during parsing and indexing, in particular to set the host field. It also uses the host field at search time.

The <string> is prepended with 'host::'.

The IP address or fully-qualified domain name of the host where the data originated.
index = <string> Sets the index where Splunk software should store the events from this input. The <string> is prepended with 'index::'. main or whatever you set the default index to
sourcetype = <string> Sets the sourcetype key/field for events from this input. Also declares the source type for this data, instead of letting Splunk software determine it. This is important both for searchability and for applying the relevant formatting for this type of data during parsing and indexing.

Sets the sourcetype key initial value. Splunk software uses the key during parsing and indexing, in particular to set the sourcetype field during indexing. It also uses the sourcetype field at search time.

The <string> is prepended with 'sourcetype::'.

Splunk software picks a source type based on various aspects of the data. There is no hard-coded default.
source = <string> Sets the source key/field for events from this input. The <string> is prepended with 'source::'.

Do not override the source key unless absolutely necessary. The input layer provides a more accurate string to aid in problem analysis and investigation by recording the file from which the data was retrieved. Consider use of source types, tagging, and search wildcards before overriding this value.

The input file path
queue = parsingQueue | indexQueue Specifies where the input processor should deposit the events that it reads.

Set to "parsingQueue" to apply props.conf and other parsing rules to your data. Set to "indexQueue" to send your data directly into the index.

parsingQueue
connection_host = ip | dns | none "ip" sets the host to the IP address of the remote server.

"dns" sets the host to the DNS entry of the remote server.

"none" leaves the host as specified.

ip

A UDP input stanza is similar to the TCP type, except that it listens on a UDP port.

The following UDP input stanza tells the forwarder to listen to <remote server> on <port>. If <remote server> is blank, the forwarder listens to all connections on the specified port.

[udp://<remote server>:<port>]
<attrbute1> = <val1>
<attrbute2> = <val2>
...

The UDP input stanza supports the following attributes.

Attribute Description Default
host = <string> Sets the host key/field to a static value for this stanza. Also sets the host key initial value. Splunk software uses this key during parsing and indexing, in particular to set the host field. It also uses the host field at search time. The <string> is prepended with 'host::'. The IP address or fully-qualified domain name of the host where the data originated.
index = <string> Sets the index where Splunk software should store events from this input. The <string> is prepended with 'index::'. main or whatever you set the default index to
sourcetype = <string> Sets the sourcetype key/field for events from this input. Also declares the source type for this data, as opposed to letting Splunk software determine it. This is important both for searchability and for applying the relevant formatting for this type of data during parsing and indexing.

Sets the sourcetype key initial value. Splunk software uses the key during parsing and indexing, in particular to set the sourcetype field during indexing. It also uses the sourcetype field at search time.

The <string> is prepended with 'sourcetype::'.

Splunk software picks a source type based on various aspects of the data. There is no hard-coded default.
source = <string> Sets the source key/field for events from this input. The <string> is prepended with 'source::'.

Do not override the source key unless absolutely necessary. The input layer provides a more accurate string to aid in problem analysis and investigation by recording the file from which the data was retrieved. Consider use of source types, tagging, and search wildcards before overriding this value.

The input file path
queue = parsingQueue | indexQueue Sets where the input processor should deposit the events that it reads. Set to "parsingQueue" to apply props.conf and other parsing rules to your data. Set to "indexQueue" to send your data directly into the index. parsingQueue
_rcvbuf = <integer> Sets the receive buffer for the UDP port, in bytes. If the value is 0 or negative, the Splunk platform ignores the value. 1,572,864 unless the value is too large for an OS. In this case, Splunk software halves the value from this default continuously until the buffer size is at an acceptable level.
no_priority_stripping = true | false Sets how Splunk software handles receiving syslog data.

If you set this attribute to true, Splunk software does not strip the <priority> syslog field from received events.

Depending on how you set this attribute, Splunk software also sets event timestamps differently. When set to true, Splunk software honors the timestamp as it comes from the source. When set to false, Splunk software assigns events the local time.

false (Splunk software strips <priority>.)
no_appending_timestamp = true | false Sets how Splunk software applies timestamps and hosts to events.

If you set this attribute to true, Splunk software does not append a timestamp and host to received events.

Do not set this attribute if you want to append timestamp and host to received events.

false (Splunk software appends timestamps and hosts to events)

Answers

Have questions? Visit Splunk Answers and see what and answers the Splunk community has about questions UDP inputs, TCP inputs, and inputs in general,

PREVIOUS
How Splunk Cloud handles log file rotation
  NEXT
How Splunk Cloud handles syslog data over UDP

This documentation applies to the following versions of Splunk Cloud: 7.1.3, 7.1.6, 7.2.3, 7.2.4, 7.2.6, 7.2.7


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