File

Output observability events into files

status: beta delivery: at-least-once egress: stream state: stateless

Configuration

Example configurations

{
  "sinks": {
    "my_sink_id": {
      "type": "file",
      "inputs": "my-source-or-transform-id",
      "compression": "none",
      "path": "/tmp/vector-%Y-%m-%d.log"
    }
  }
}
[sinks.my_sink_id]
type = "file"
inputs = "my-source-or-transform-id"
compression = "none"
path = "/tmp/vector-%Y-%m-%d.log"
---
sinks:
  my_sink_id:
    type: file
    inputs: my-source-or-transform-id
    compression: none
    encoding: null
    healthcheck: null
    path: /tmp/vector-%Y-%m-%d.log
{
  "sinks": {
    "my_sink_id": {
      "type": "file",
      "inputs": "my-source-or-transform-id",
      "idle_timeout_secs": 30,
      "compression": "none",
      "path": "/tmp/vector-%Y-%m-%d.log"
    }
  }
}
[sinks.my_sink_id]
type = "file"
inputs = "my-source-or-transform-id"
idle_timeout_secs = 30
compression = "none"
path = "/tmp/vector-%Y-%m-%d.log"
---
sinks:
  my_sink_id:
    type: file
    inputs: my-source-or-transform-id
    idle_timeout_secs: 30
    compression: none
    encoding: null
    healthcheck: null
    path: /tmp/vector-%Y-%m-%d.log

compression

common optional string enum

The compression strategy used to compress the encoded event data before transmission.

Some cloud storage API clients and browsers will handle decompression transparently, so files may not always appear to be compressed depending how they are accessed.

Enum options string literal
OptionDescription
gzipGzip standard DEFLATE compression.
noneNo compression.
syntaxliteral
default: none

encoding

required object
Configures the encoding specific sink behavior.

encoding.codec

required string literal
The encoding codec used to serialize the events before outputting.

encoding.except_fields

optional array
Prevent the sink from encoding the specified fields.

encoding.only_fields

optional array
Makes the sink encode only the specified fields.

encoding.timestamp_format

optional string enum literal
How to format event timestamps.
Enum options
OptionDescription
rfc3339Formats as a RFC3339 string
unixFormats as a unix timestamp
default: rfc3339

healthcheck

common optional object
Health check options for the sink.

healthcheck.enabled

optional bool
Enables/disables the healthcheck upon Vector boot.
default: true

idle_timeout_secs

optional uint
The amount of time a file can be idle and stay open. After not receiving any events for this timeout, the file will be flushed and closed.
default: 30

inputs

required [string]

A list of upstream source or transform IDs. Wildcards (*) are supported but must be the last character in the ID.

See configuration for more info.

Array string literal
Examples
[
  "my-source-or-transform-id",
  "prefix-*"
]

path

required string
File name to write events to.

Telemetry

Metrics

link

events_discarded_total

counter
The total number of events discarded by this component.

events_in_total

counter
The number of events accepted by this component either from tagged origin like file and uri, or cumulatively from other origins.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
container_name optional
The name of the container from which the event originates.
file optional
The file from which the event originates.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the event originates.
peer_path optional
The pathname from which the event originates.
pod_name optional
The name of the pod from which the event originates.
uri optional
The sanitized URI from which the event originates.

events_out_total

counter
The total number of events emitted by this component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

processing_errors_total

counter
The total number of processing errors encountered by this component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
error_type required
The type of the error

How it works

File & Directory Creation

Vector will attempt to create the entire directory structure and the file when emitting events to the file sink. This requires that the Vector agent have the correct permissions to create and write to files in the specified directories.

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.

State

This component is stateless, meaning its behavior is consistent across each input.