Socket Source

The Vector socket source ingests data through a socket, such as a TCP, UDP, or Unix socket and outputs log events.

Configuration

  • Common
  • Advanced
vector.toml
[sources.my_source_id]
# REQUIRED - General
type = "socket" # must be: "socket"
address = "0.0.0.0:9000" # example, relevant when mode = "tcp" or mode = "udp"
mode = "tcp" # example, enum
# OPTIONAL - General
shutdown_timeout_secs = 30 # default, seconds, relevant when mode = "tcp"
path = "/path/to/socket" # example, no default, relevant when mode = "unix"
# OPTIONAL - Context
host_key = "host" # default

Options

6 items
commonstringrequired

address

The address to listen for connections on, or systemd#N to use the Nth socket passed by systemd socket activation. If an address is used it must include a port.

No default
Only relevant when: mode = ["tcp","udp"]
View examples
commonstringrequired

host_key

The key name added to each event representing the current host. See Context for more info.

Default: "host"
View examples
intbytesoptional

max_length

The maximum bytes size of incoming messages before they are discarded.

Default: 102400
View examples
commonstringenumrequired

mode

The type of socket to use.

No default
Enum, must be one of: "tcp" "udp" "unix"
View examples
commonstringoptional

path

The unix socket path. This should be absolute path.

No default
Only relevant when: mode = "unix"
View examples
commonintsecondsrequired

shutdown_timeout_secs

The timeout before a connection is forcefully closed during shutdown.

Default: 30
Only relevant when: mode = "tcp"
View examples

Output

The socket source ingests data through a socket, such as a TCP, UDP, or Unix socket and outputs log events. For example:

More detail on the output schema is below.

3 items
stringrequired

host

The upstream hostname.

No default
View examples
stringrequired

message

The raw message, unaltered.

No default
View examples
timestamprequired

timestamp

The exact time the event was ingested.

No default
View examples

How It Works

Context

By default, the socket source will add context keys to your events via the host_key options.

Environment Variables

Environment variables are supported through all of Vector's configuration. Simply add ${MY_ENV_VAR} in your Vector configuration file and the variable will be replaced before being evaluated.

You can learn more in the Environment Variables section.