Network Split
Synopsis
Splits a combined host:port address string into separate IP address and port fields using Go's standard net.SplitHostPort parser.
Schema
- network_split:
field: <ident>
ip_field: <ident>
port_field: <ident>
description: <text>
if: <script>
tag: <string>
on_success: <processor[]>
on_failure: <processor[]>
ignore_missing: <boolean>
ignore_failure: <boolean>
disabled: <boolean>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | Source field containing the host:port address string | |
ip_field | Y | Target field to write the extracted host or IP address | |
port_field | N | Target field to write the extracted port number | |
description | N | Explanatory text | |
if | N | Condition to run | |
tag | N | Identifier for logging | |
on_success | N | See Handling Success | |
on_failure | N | See Handling Failures | |
ignore_missing | N | false | If true, exit quietly when field does not exist |
ignore_failure | N | false | See Handling Failures |
disabled | N | false | Disable the processor |
Details
The processor reads the value of field and parses it using net.SplitHostPort. The extracted host component is written to ip_field. The port component is written to port_field only when port_field is specified and a port is present in the source value. When the source value contains no port, port_field is not created.
The source field value must be a string. Non-string values cause an error that can be suppressed with ignore_failure.
IPv4 addresses in host:port format (192.168.1.100:8080), IPv6 addresses in bracketed format ([2001:db8::1]:443), and hostnames (example.com:443) are all accepted. Bare IPv4 addresses without a port (10.0.0.5) and bare IPv6 addresses (2001:db8::1) are also accepted and write only the host component to ip_field.
Examples
IPv4 Address with Port
Splitting an IPv4 address and port from a combined field... | |
Processor writes IP and port to separate fields... | |
IPv6 Address with Port
Splitting an IPv6 address in bracketed notation... | |
Processor extracts the IPv6 address without brackets... | |
Address Without Port
Processing a bare IP address with no port present... | |
Only the IP field is written; port field is not created when no port exists... | |
Hostname with Port
Splitting a hostname and port from an endpoint field... | |
Processor writes the hostname and port to separate fields... | |
IP Only Extraction
Extracting only the IP address when port output is not needed... | |
Only the IP field is written; port is discarded... | |