GCP Cloud Storage (GCS)

Store observability events in GCP Cloud Storage

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

Configuration

Example configurations

{
  "sinks": {
    "my_sink_id": {
      "type": "gcp_cloud_storage",
      "inputs": "my-source-or-transform-id",
      "bucket": "my-bucket",
      "credentials_path": "/path/to/credentials.json",
      "key_prefix": "date=%F/",
      "compression": "none"
    }
  }
}
[sinks.my_sink_id]
type = "gcp_cloud_storage"
inputs = "my-source-or-transform-id"
bucket = "my-bucket"
credentials_path = "/path/to/credentials.json"
key_prefix = "date=%F/"
compression = "none"
---
sinks:
  my_sink_id:
    type: gcp_cloud_storage
    inputs: my-source-or-transform-id
    bucket: my-bucket
    credentials_path: /path/to/credentials.json
    key_prefix: date=%F/
    compression: none
    encoding: null
    healthcheck: null
{
  "sinks": {
    "my_sink_id": {
      "type": "gcp_cloud_storage",
      "inputs": "my-source-or-transform-id",
      "acl": "authenticated-read",
      "bucket": "my-bucket",
      "credentials_path": "/path/to/credentials.json",
      "filename_append_uuid": true,
      "filename_extension": "log",
      "filename_time_format": "%s",
      "key_prefix": "date=%F/",
      "metadata": null,
      "compression": "none",
      "storage_class": "STANDARD"
    }
  }
}
[sinks.my_sink_id]
type = "gcp_cloud_storage"
inputs = "my-source-or-transform-id"
acl = "authenticated-read"
bucket = "my-bucket"
credentials_path = "/path/to/credentials.json"
filename_append_uuid = true
filename_extension = "log"
filename_time_format = "%s"
key_prefix = "date=%F/"
compression = "none"
storage_class = "STANDARD"
---
sinks:
  my_sink_id:
    type: gcp_cloud_storage
    inputs: my-source-or-transform-id
    acl: authenticated-read
    bucket: my-bucket
    credentials_path: /path/to/credentials.json
    filename_append_uuid: true
    filename_extension: log
    filename_time_format: "%s"
    key_prefix: date=%F/
    metadata: null
    buffer: null
    batch: null
    compression: none
    encoding: null
    healthcheck: null
    request: null
    tls: null
    storage_class: STANDARD

acl

optional string enum
Predefined ACL to apply to the created objects. For more information, see Predefined ACLs. If this is not set, GCS will apply a default ACL when the object is created.
Enum options string literal
OptionDescription
authenticated-readGives the bucket or object owner OWNER permission, and gives all authenticated Google account holders READER permission.
bucket-owner-full-controlGives the object and bucket owners OWNER permission.
bucket-owner-readGives the object owner OWNER permission, and gives the bucket owner READER permission.
privateGives the bucket or object owner OWNER permission for a bucket or object.
project-privateGives permission to the project team based on their roles. Anyone who is part of the team has READER permission. Project owners and project editors have OWNER permission. This the default.
public-readGives the bucket or object owner OWNER permission, and gives all users, both authenticated and anonymous, READER permission. When you apply this to an object, anyone on the Internet can read the object without authenticating.

batch

optional object
Configures the sink batching behavior.

batch.max_bytes

optional uint
The maximum size of a batch, in bytes, before it is flushed.
default: 1.048576e+07 (bytes)

batch.timeout_secs

optional uint
The maximum age of a batch before it is flushed.
default: 300 (seconds)

bucket

required string
The GCS bucket name.

buffer

optional object
Configures the sink specific buffer behavior.

buffer.max_events

optional uint
The maximum number of events allowed in the buffer.
Relevant when: type = "memory"
default: 500 (events)

buffer.max_size

required uint
The maximum size of the buffer on the disk.
Relevant when: type = "disk"

buffer.type

optional string enum literal
The buffer’s type and storage mechanism.
Enum options
OptionDescription
diskStores the sink’s buffer on disk. This is less performant, but durable. Data will not be lost between restarts. Will also hold data in memory to enhance performance. WARNING: This may stall the sink if disk performance isn’t on par with the throughput. For comparison, AWS gp2 volumes are usually too slow for common cases.
memoryStores the sink’s buffer in memory. This is more performant, but less durable. Data will be lost if Vector is restarted forcefully.
default: memory

buffer.when_full

optional string enum literal
The behavior when the buffer becomes full.
Enum options
OptionDescription
blockApplies back pressure when the buffer is full. This prevents data loss, but will cause data to pile up on the edge.
drop_newestDrops new data as it’s received. This data is lost. This should be used when performance is the highest priority.
default: block

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.
default: none

credentials_path

common optional string

The filename for a Google Cloud service account credentials JSON file used to authenticate access to the Cloud Storage API. If this is unset, Vector checks the GOOGLE_APPLICATION_CREDENTIALS environment variable for a filename.

If no filename is named, Vector will attempt to fetch an instance service account for the compute instance the program is running on. If Vector is not running on a GCE instance, you must define a credentials file as above.

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

filename_append_uuid

optional bool
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.
default: true

filename_extension

optional string
The filename extension to use in the object name.
default: log

filename_time_format

optional string
The format of the resulting object file name. strftime specifiers are supported.
default: %s

healthcheck

common optional object
Health check options for the sink.

healthcheck.enabled

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

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-*"
]

key_prefix

common optional string
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 GCS “folder”.
default: date=%F/

metadata

optional string
The set of metadata key:value pairs for the created objects. See the GCS custom metadata documentation for more details.

request

optional object
Configures the sink request behavior.

request.adaptive_concurrency

optional object
Configure the adaptive concurrency algorithms. These values have been tuned by optimizing simulated results. In general you should not need to adjust these.

request.concurrency

optional uint
The maximum number of in-flight requests allowed at any given time.
default: 25 (requests)

request.rate_limit_duration_secs

optional uint
The time window, in seconds, used for the rate_limit_num option.
default: 1 (seconds)

request.rate_limit_num

optional uint
The maximum number of requests allowed within the rate_limit_duration_secs time window.
default: 1000

request.retry_attempts

optional uint
The maximum number of retries to make for failed requests. The default, for all intents and purposes, represents an infinite number of retries.
default: 1.8446744073709552e+19

request.retry_initial_backoff_secs

optional uint
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 (seconds)

request.retry_max_duration_secs

optional uint
The maximum amount of time, in seconds, to wait between retries.
default: 10 (seconds)

request.timeout_secs

optional uint
The maximum time a request can take before being aborted. It is highly recommended that you do not lower this value below the service’s internal timeout, as this could create orphaned requests, pile on retries, and result in duplicate data downstream.
default: 60 (seconds)

storage_class

optional string enum
The storage class for the created objects. See the GCP storage classes for more details.
Enum options string literal
OptionDescription
ARCHIVEArchive Storage is the lowest-cost, highly durable storage service for data archiving, online backup, and disaster recovery.
COLDLINEColdline Storage is a very-low-cost, highly durable storage service for storing infrequently accessed data.
NEARLINENearline Storage is a low-cost, highly durable storage service for storing infrequently accessed data.
STANDARDStandard Storage is best for data that is frequently accessed and/or stored for only brief periods of time. This is the default.

tls

optional object
Configures the TLS options for incoming connections.

tls.ca_file

optional string literal
Absolute path to an additional CA certificate file, in DER or PEM format (X.509), or an inline CA certificate in PEM format.

tls.crt_file

optional string literal
Absolute path to a certificate file used to identify this connection, in DER or PEM format (X.509) or PKCS#12, or an inline certificate in PEM format. If this is set and is not a PKCS#12 archive, key_file must also be set.

tls.key_file

optional string literal
Absolute path to a private key file used to identify this connection, in DER or PEM format (PKCS#8), or an inline private key in PEM format. If this is set, crt_file must also be set.

tls.key_pass

optional string literal
Pass phrase used to unlock the encrypted key file. This has no effect unless key_file is set.

tls.verify_hostname

optional bool
If true (the default), Vector will validate the configured remote host name against the remote host’s TLS certificate. Do NOT set this to false unless you understand the risks of not verifying the remote hostname.
default: true

Environment variables

GOOGLE_APPLICATION_CREDENTIALS

common optional string literal
The filename for a Google Cloud service account credentials JSON file used for authentication.
Examples
/path/to/credentials.json

Telemetry

Metrics

link

events_discarded_total

counter
The total number of events discarded by this component.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

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.
host required
The hostname of the system Vector is running on.
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.
pid required
The process ID of the Vector instance.
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.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

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
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

Permissions

Platform: Google Cloud Platform
Relevant policies
PolicyRequired forRequired when
storage.objects.createwrite
storage.objects.gethealthcheck

How it works

Buffers and batches

This component 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 or max_events.

Buffers are controlled via the buffer.* options.

GCP Authentication

GCP offers a variety of authentication methods and Vector is concerned with the server to server methods and will find credentials in the following order:

  1. If the credentials_path option is set.
  2. If the api_key option is set.
  3. If the GOOGLE_APPLICATION_CREDENTIALS envrionment variable is set.
  4. Finally, Vector will check for an instance service account.

If credentials aren’t found, Vector’s health checks fail and an error is logged.

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 access control list (ACL)

GCP Cloud Storage supports access control lists (ACL) for buckets and objects. In the context of Vector, only object ACLs are relevant (Vector does not create or modify buckets). You can set the object level ACL by using the acl option, which allows you to set one of the predefined ACLs on each created object.

Object naming

By default, Vector names your GCS objects in accordance with one of two formats.

If compression is enabled, this format is used:

key_prefix><timestamp>-<uuidv4>.log.gz

Here’s an example name in the compression-enabled format:

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

If compression is not enabled, this format is used:

<key_prefix><timestamp>-<uuidv4>.log

Here’s an example name in the compression-disabled format:

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 that two 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

Vector supports dynamic configuration values through a simple template syntax. If an option supports templating, it will be noted with a badge and you can use event fields to create dynamic values. For example:

[sinks.my-sink]
dynamic_option = "application={{ application_id }}"

In the above example, the application_id for each event will be used to partition outgoing data.

Rate limits & adapative concurrency

Adaptive Request Concurrency (ARC)

Adaptive Requst Concurrency is a feature of Vector that does away with static rate limits and automatically optimizes HTTP concurrency limits based on downstream service responses. The underlying mechanism is a feedback loop inspired by TCP congestion control algorithms. Checkout the announcement blog post,

We highly recommend enabling this feature as it improves performance and reliability of Vector and the systems it communicates with.

To enable, set the request.concurrency option to adaptive:

[sinks.my-sink]
  request.concurrency = "adaptive"

Static rate limits

If Adaptive Request Concurrency is not for you, you can manually set static rate limits with the request.rate_limit_duration_secs, request.rate_limit_num, and request.concurrency options:

[sinks.my-sink]
  request.rate_limit_duration_secs = 1
  request.rate_limit_num = 10
  request.concurrency = 10

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 request.retry_attempts and request.retry_backoff_secs options.

State

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

Storage Class

GCS offers storage classes. You can apply defaults, and rules, at the bucket level or set the storage class at the object level. In the context of Vector only the object level is relevant (Vector does not create or modify buckets). You can set the storage class via the storage_class option.

Tags & Metadata

Vector supports adding custom metadata to created objects. These metadata items are a way of associating extra data items with the object that are not part of the uploaded data.

Transport Layer Security (TLS)

Vector uses OpenSSL for TLS protocols due to OpenSSL’s maturity. You can enable and adjust TLS behavior using the tls.* options.