GCP Stackdriver Logging Sink

The Vector gcp_stackdriver_logging sink batches log events to Google Cloud Platform's Stackdriver Logging service via the REST Interface.

Configuration

  • Common
  • Advanced
vector.toml
[sinks.my_sink_id]
# REQUIRED
type = "gcp_stackdriver_logging" # must be: "gcp_stackdriver_logging"
inputs = ["my-source-id"] # example
credentials_path = "/path/to/credentials.json" # example
log_id = "vector-logs" # example
project_id = "vector-123456" # example
# OPTIONAL
healthcheck = true # default

Options

12 items
tableoptional

batch

Configures the sink batching behavior.

int (bytes)commonrequired

max_size

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

Default: 5242880 (bytes)
View examples
int (seconds)commonrequired

timeout_secs

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

Default: 1 (seconds)
View examples
stringoptional

billing_account_id

The billing account ID to which to publish logs.

Exactly one of billing_account_id, folder_id, organization_id, or project_id must be set.

No default
View examples
tableoptional

buffer

Configures the sink specific buffer behavior.

int (events)commonrequired

max_events

The maximum number of events allowed in the buffer.

Default: 500 (events)
Only relevant when: type = "memory"
View examples
int (bytes)commonrequired

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
stringenumcommonrequired

type

The buffer's type and storage mechanism.

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
stringcommonrequired

credentials_path

The filename for a Google Cloud service account credentials JSON file used to authenticate access to the Stackdriver Logging API. If this is unset, Vector checks the $GOOGLE_APPLICATION_CREDENTIALS environment variable for a filename. See GCP Authentication for more info.

No default
View examples
stringoptional

folder_id

The folder ID to which to publish logs. See the Google Cloud Platform folder documentation for more details.

Exactly one of billing_account_id, folder_id, organization_id, or project_id must be set.

No default
View examples
boolcommonoptional

healthcheck

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

Default: true
View examples
stringcommonrequired

log_id

The log ID to which to publish logs. This is a name you create to identify this log stream.

No default
View examples
stringoptional

organization_id

The organization ID to which to publish logs. This would be the identifier assigned to your organization on Google Cloud Platform.

Exactly one of billing_account_id, folder_id, organization_id, or project_id must be set.

No default
View examples
stringcommonrequired

project_id

The project ID to which to publish logs. See the Google Cloud Platform project management documentation for more details.

Exactly one of billing_account_id, folder_id, organization_id, or project_id must be set.

No default
View examples
tableoptional

request

Configures the sink request behavior.

int (requests)optional

in_flight_limit

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

Default: 5 (requests)
View examples
int (seconds)optional

rate_limit_duration_secs

The time window, in seconds, used for the rate_limit_num option. See Rate Limits for more info.

Default: 1 (seconds)
View examples
intoptional

rate_limit_num

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

Default: 1000
View examples
intoptional

retry_attempts

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

Default: -1
View examples
int (seconds)optional

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 (seconds)
View examples
int (seconds)optional

retry_max_duration_secs

The maximum amount of time, in seconds, to wait between retries.

Default: 10 (seconds)
View examples
int (seconds)optional

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 duplicate data downstream. See Buffers & Batches for more info.

Default: 60 (seconds)
View examples
tableoptional

resource

Options for describing the logging resource.

stringcommonrequired

type

The monitored resource type. For example, the type of a Compute Engine VM instance is gce_instance.

See the Google Cloud Platform monitored resource documentation for more details.

No default
View examples
stringoptional

[label]

Values for all of the labels listed in the associated monitored resource descriptor.

For example, Compute Engine VM instances use the labels projectId, instanceId, and zone.

No default
View examples
tableoptional

tls

Configures the TLS options for connections from this sink.

stringoptional

ca_path

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

No default
View examples
stringoptional

crt_path

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

No default
View examples
stringoptional

key_pass

Pass phrase used to unlock the encrypted key file. This has no effect unless key_path is set.

No default
View examples
stringoptional

key_path

Absolute path to a certificate key file used to identify this connection, in DER or PEM format (PKCS#8). If this is set, crt_path must also be set.

No default
View examples
booloptional

verify_certificate

If true (the default), Vector will validate the TLS certificate of the remote host. Do NOT set this to false unless you understand the risks of not verifying the remote certificate.

Default: true
View examples
booloptional

verify_hostname

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
View examples

Env Vars

stringcommonoptional

GOOGLE_APPLICATION_CREDENTIALS

The filename for a Google Cloud service account credentials JSON file used to authenticate access to the Stackdriver Logging API. See GCP Authentication for more info.

No default
View examples

How It Works

Buffers & Batches

The gcp_stackdriver_logging 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.

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. Finally, if the GOOGLE_APPLICATION_CREDENTIALS envrionment variable is set.

If credentials are not found the healtcheck will fail and an error will be 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.

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.