15.1 Input-Phase Processing & Default Metadata Assignment
Key Takeaways
- The input assigns host, source, sourcetype, and index from inputs.conf before parsing; index defaults to the default index (main) and host to the [default] host name.
- host_segment = N uses the Nth /-separated path segment; on Windows the drive letter does not count, so D:\logs\servers\host01 with host_segment = 3 gives host01.
- host_regex uses the first capture group matched against the source value, and if host_regex and host_segment are both set, host_regex is ignored.
- connection_host defaults to dns for TCP inputs and ip for UDP inputs; none keeps the host configured in inputs.conf.
- In props.conf, [source::] settings override [host::], which override [<sourcetype>]; setting sourcetype explicitly avoids automatic classification and generic default parsing.
Input-Phase Processing & Default Metadata Assignment
Quick Summary: Every event carries four default metadata fields:
host,source,sourcetype, andindex. They are assigned by the input that reads the data, on the forwarder or on the first full Splunk instance, before parsing starts. You control them ininputs.confwith static values, path-based host extraction (host_segment,host_regex), andconnection_hostfor network inputs. Setting them explicitly, especiallysourcetype, is what makes the later parsing rules inprops.confapply correctly.
Where Metadata Is Assigned in the Pipeline
Splunk's data pipeline starts with the input segment, followed by the parsing, merging, typing, and index pipelines (covered in detail in the staging chapter):
- Input: the input reads the data (file, network port, script, Windows API), breaks it into blocks, and attaches
host,source,sourcetype, andindexfrominputs.conf. Character encoding (CHARSET) is also applied here. - Parsing pipeline: line breaking (
LINE_BREAKER) and header processing. - Merging pipeline: timestamp extraction and, when
SHOULD_LINEMERGE = true, line merging. - Typing pipeline: regex-based
TRANSFORMSandSEDCMD, such as masking, routing, and metadata rewrites. - Index pipeline: writing raw data and index files to buckets, or forwarding.
Why Input-Time Metadata Matters
props.confmatching: parsing settings are found by matching the event's metadata againstprops.confstanzas. When several stanzas match,[source::<source>]overrides[host::<host>], which overrides[<sourcetype>].rule::anddelayedrule::stanzas are only used to classify data that has no source type. If the input assigns the wrong source type, the right parsing rules never run.- Routing and filtering: transforms that send events to other indexes, output groups, or the
nullQueueusually key onhost,source, orsourcetype. - Index placement: the
indexsetting decides where data lands and therefore which roles can search it and which retention settings apply. It defaults to thedefaultindex (main).
Host Assignment in inputs.conf
1. Static Host (host = <value>)
Every event from the stanza gets that host value. If a stanza does not set host, the value comes from the [default] stanza of inputs.conf, which Splunk sets to the machine's host name at installation.
[monitor:///opt/oracle/admin/diag/rdbms/prod/alert.log]
host = db-cluster-primary.corp.example
sourcetype = oracle:alert:log
index = databases
2. Host from a Path Segment (host_segment = <N>)
When a central server stores logs in per-host directories (for example, a syslog server writing /var/log/remote_hosts/<host>/...), host_segment uses the Nth /-separated segment of the path as the host.
Path: /var/log/remote_hosts/web-prod-01/nginx/access.log
| Segment | Value |
|---|---|
| 1 | var |
| 2 | log |
| 3 | remote_hosts |
| 4 | web-prod-01 |
| 5 | nginx |
| 6 | access.log |
[monitor:///var/log/remote_hosts/.../*.log]
host_segment = 4
sourcetype = nginx:access
index = web_logs
- If the value is not an integer or is less than 1, the default
hostsetting is used. - Windows: the drive letter and colon do not count as a segment. With
host_segment = 3and the pathD:\logs\servers\host01, the host ishost01.
3. Host from a Regular Expression (host_regex = <regex>)
When host names sit at varying depths or inside file names, host_regex applies a regex to the path and uses the first capturing group as the host.
[monitor:///mnt/storage/.../logs/*.log]
host_regex = /mnt/storage/(?:prod|dr)/([^/]+)/
[monitor:///var/log/syslog-*.log]
host_regex = syslog-[a-z]+-([a-zA-Z0-9-]+)\.corp\.log
- The regex is matched against the source value. If
sourceis set explicitly in the stanza, that string is matched instead of the file name. - If the regex does not match, the default
hostsetting is used.
Which Setting Wins?
Per inputs.conf.spec: if host_regex and host_segment are both set, host_regex is ignored. If the chosen method does not produce a value, the stanza's host, or the [default] host, is used. A source type with a host-override transform (as with syslog data) can still replace host later in the typing pipeline.
4. Network Inputs (connection_host)
For [tcp://] and [udp://] inputs, the host usually comes from the sender:
| Value | Behavior | Default for |
|---|---|---|
dns | Reverse DNS name of the sender's IP; forward and reverse DNS should match | TCP inputs |
ip | The sender's IP address, with no lookup | UDP inputs |
none | Keep the host set in inputs.conf, typically the receiving instance's host name | – |
For [splunktcp] inputs, the forwarder normally sends its own host value. connection_host is used only if the remote instance does not set a host. When data passes through a relay, the sender's address is the relay's, so extract the true host from the event (for example, the syslog header) with a host-override transform.
Source Type Assignment
The source type decides how Splunk breaks events, finds timestamps, and applies field extractions.
Explicit vs. Automatic
- Explicit (
sourcetype = <name>): you name the source type in the input. This is the best practice for every production input. - Automatic: if the input sets no source type, Splunk tries to recognize the data. It uses its pretrained source types and the
rule::anddelayedrule::stanzas inprops.conf, and as a last resort it generates a new source type based on the source. Very small files can end up astoo_smallor<sourcename>-too_small.
Why Automatic Source Typing Is Avoided in Production
- Inconsistent names: similar files can be classified differently depending on their content, and learned names such as
app-too_smallor generated source types do not match what add-ons, dashboards, and data models expect. - Generic parsing: a source type with no specific settings runs on the
[default]values inprops.conf, such asSHOULD_LINEMERGE = trueandMAX_TIMESTAMP_LOOKAHEAD = 128. These defaults are slower and less accurate than a tuned source type withLINE_BREAKER,SHOULD_LINEMERGE = false,TIME_PREFIX, andTIME_FORMAT. - Knowledge objects: event types, tags, field aliases, and CIM data models are usually written for specific source type names such as
cisco:asaorpan:traffic.
Best practice: set
sourcetypeexplicitly in every input stanza, preferably using the names that the relevant Splunkbase add-on expects.
Source Assignment and Overrides
By default, source is:
- Monitored files: the full path of the file, such as
/var/log/apache2/access.log. - Network inputs: the protocol and port, such as
udp:514ortcp:1514. - Scripted and modular inputs: the script path or input name.
source = <name> in the stanza overrides it. This is rarely necessary for files, because the path is valuable information, but it can help when paths contain random container IDs. Remember that host_regex matches the overridden value.
An enterprise infrastructure team monitors application logs aggregated from remote Linux web servers onto a central storage volume under the directory structure /mnt/central_logs/ecommerce/web-prod-04/nginx/access.log. The administrator configures a monitor stanza in inputs.conf using [monitor:///mnt/central_logs/.../*.log]. Which configuration correctly extracts web-prod-04 as the host metadata field?
A monitor stanza sets both host_segment = 4 and host_regex = /logs/([^/]+)/. Which setting determines the host value?
Why is relying on Splunk's automatic sourcetyping heuristics (rule:: classification) strictly avoided in production enterprise environments?