AWS S3 Sink

The Vector aws_s3 sink batches log events to Amazon Web Service's S3 service via the PutObject API endpoint.

Configuration

  • Common
  • Advanced
vector.toml
[sinks.my_sink_id]
# REQUIRED - General
type = "aws_s3" # must be: "aws_s3"
inputs = ["my-source-id"] # example
bucket = "my-bucket" # example
compression = "gzip" # example, enum
# OPTIONAL - Object Names
filename_append_uuid = true # default
filename_extension = "log" # default
filename_time_format = "%s" # default
key_prefix = "date=%F/" # default
# OPTIONAL - General
region = "us-east-1" # example, no default

Options

13 items
tableoptional

batch

Configures the sink batching behavior.

intbytesoptional

max_size

The maximum size of a batch before it is flushed. See Buffers & Batches for more info.

Default: 10490000
View examples
intsecondsoptional

timeout_secs

The maximum age of a batch before it is flushed. See Buffers & Batches for more info.

Default: 300
View examples
commonstringrequired

bucket

The S3 bucket name. Do not include a leading s3:// or a trailing /.

No default
View examples
tableoptional

buffer

Configures the sink buffer behavior.

inteventsoptional

max_events

The maximum number of events allowed in the buffer.

Default: 500
Only relevant when: type = "memory"
View examples
intbytesoptional

max_size

The maximum size of the buffer on the disk. See Buffers & Batches for more info.

No default
Only relevant when: type = "disk"
View examples
stringenumoptional

type

The buffer's type / location. disk buffers are persistent and will be retained between restarts.

Default: "memory"
Enum, must be one of: "memory" "disk"
View examples
stringenumoptional

when_full

The behavior when the buffer becomes full.

Default: "block"
Enum, must be one of: "block" "drop_newest"
View examples
commonstringenumrequired

compression

The compression mechanism to use.

No default
Enum, must be one of: "gzip" "none"
View examples
stringenumoptional

encoding

The encoding format used to serialize the events before outputting.

No default
Enum, must be one of: "ndjson" "text"
View examples
stringoptional

endpoint

The endpoint of the target S3 bucket. Either "endpoint" or "region" must be specified.

No default
View examples
commonboolrequired

filename_append_uuid

Whether or not to append a UUID v4 token to the end of the file. This ensures there are no name collisions high volume use cases. See Object Naming for more info.

Default: true
View examples
commonstringrequired

filename_extension

The extension to use in the object name.

Default: "log"
View examples
commonstringrequired

filename_time_format

The format of the resulting object file name. strftime specifiers are supported. See Object Naming for more info.

Default: "%s"
View examples
booloptional

healthcheck

Enables/disables the sink healthcheck upon start. See Health Checks for more info.

Default: true
View examples
commontemplateablestringoptional

key_prefix

A prefix to apply to all object key names. This should be used to partition your objects, and it's important to end this value with a / if you want this to be the root S3 "folder". See Object Naming, Partitioning, and Template Syntax for more info.

Default: "date=%F/"
View examples
commonstringoptional

region

The AWS region of the target S3 bucket. Either "region" or "endpoint" must be specified.

No default
View examples
tableoptional

request

Configures the sink request behavior.

intoptional

in_flight_limit

The maximum number of in-flight requests allowed at any given time. See Rate Limits for more info.

Default: 5
View examples
intsecondsoptional

rate_limit_duration_secs

The window used for the rate_limit_num option See Rate Limits for more info.

Default: 1
View examples
intoptional

rate_limit_num

The maximum number of requests allowed within the rate_limit_duration_secs window. See Rate Limits for more info.

Default: 5
View examples
intoptional

retry_attempts

The maximum number of retries to make for failed requests. See Retry Policy for more info.

Default: 5
View examples
intsecondsoptional

retry_initial_backoff_secs

The amount of time to wait before attempting the first retry for a failed request. Once, the first retry has failed the fibonacci sequence will be used to select future backoffs.

Default: 1
View examples
intsecondsoptional

retry_max_duration_secs

The maximum amount of time to wait between retries.

Default: 10
View examples
intsecondsoptional

timeout_secs

The maximum time a request can take before being aborted. It is highly recommended that you do not lower value below the service's internal timeout, as this could create orphaned requests, pile on retries, and result in deuplicate data downstream. See Buffers & Batches for more info.

Default: 30
View examples

How It Works

Buffers & Batches

The aws_s3 sink buffers & batches data as shown in the diagram above. You'll notice that Vector treats these concepts differently, instead of treating them as global concepts, Vector treats them as sink specific concepts. This isolates sinks, ensuring services disruptions are contained and delivery guarantees are honored.

Batches are flushed when 1 of 2 conditions are met:

  1. The batch age meets or exceeds the configured timeout_secs.
  2. The batch size meets or exceeds the configured max_size.

Buffers are controlled via the buffer.* 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.

Health Checks

Health checks ensure that the downstream service is accessible and ready to accept data. This check is performed upon sink initialization. If the health check fails an error will be logged and Vector will proceed to start.

Require Health Checks

If you'd like to exit immediately upon a health check failure, you can pass the --require-healthy flag:

vector --config /etc/vector/vector.toml --require-healthy

Disable Health Checks

If you'd like to disable health checks for this sink you can set the healthcheck option to false.

Object Naming

By default, Vector will name your S3 objects in the following format:

  • Without Compression
  • With Compression
<key_prefix><timestamp>-<uuidv4>.log

For example:

date=2019-06-18/1560886634-fddd7a0e-fad9-4f7e-9bce-00ae5debc563.log

Vector appends a UUIDV4 token to ensure there are no name conflicts in the unlikely event 2 Vector instances are writing data at the same time.

You can control the resulting name via the key_prefix, filename_time_format, and filename_append_uuid options.

Partitioning

Partitioning is controlled via the key_prefix options and allows you to dynamically partition data on the fly. You'll notice that Vector's template sytax is supported for these options, enabling you to use field values as the partition's key.

Rate Limits

Vector offers a few levers to control the rate and volume of requests to the downstream service. Start with the rate_limit_duration_secs and rate_limit_num options to ensure Vector does not exceed the specified number of requests in the specified window. You can further control the pace at which this window is saturated with the in_flight_limit option, which will guarantee no more than the specified number of requests are in-flight at any given time.

Please note, Vector's defaults are carefully chosen and it should be rare that you need to adjust these. If you found a good reason to do so please share it with the Vector team by opening an issie.

Retry Policy

Vector will retry failed requests (status == 429, >= 500, and != 501). Other responses will not be retried. You can control the number of retry attempts and backoff rate with the retry_attempts and retry_backoff_secs options.

Template Syntax

The key_prefix options support Vector's template syntax, enabling dynamic values derived from the event's data. This syntax accepts strptime specifiers as well as the {{ field_name }} syntax for accessing event fields. For example:

vector.toml
[sinks.my_aws_s3_sink_id]
# ...
key_prefix = "date=%F/"
key_prefix = "date=%F/hour=%H/"
key_prefix = "year=%Y/month=%m/day=%d/"
key_prefix = "application_id={{ application_id }}/date=%F/"
# ...

You can read more about the complete syntax in the template syntax section.