InfluxDB Logs Sink

The Vector influxdb_logs sink batches log events to InfluxDB using v1 or v2 HTTP API.

Configuration

vector.toml
[sinks.my_sink_id]
# General
type = "influxdb_logs" # required
inputs = ["my-source-or-transform-id"] # required
endpoint = "https://us-west-2-1.aws.cloud1.influxdata.com" # required
namespace = "service" # required
database = "vector-database" # required
healthcheck = true # optional, default
# Auth
password = "${INFLUXDB_PASSWORD}" # optional, no default
username = "todd" # optional, no default
# Persistence
consistency = "any" # optional, no default
retention_policy_name = "autogen" # optional, no default
  • tableoptional

    batch

    Configures the sink batching behavior.

    • uint (bytes)commonoptional

      max_size

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

      • Default: 10490000 (bytes)
    • uint (seconds)commonoptional

      timeout_secs

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

      • Default: 1 (seconds)
  • stringcommonrequired

    bucket

    The destination bucket for writes into InfluxDB 2.

    • No default
    • View examples
  • tableoptional

    buffer

    Configures the sink specific buffer behavior.

    • uint (events)commonoptional

      max_events

      The maximum number of events allowed in the buffer.

      • Only relevant when: type = "memory"
      • Default: 500 (events)
    • uint (bytes)required*

      max_size

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

      • Only required when: type = "disk"
      • No default
      • View examples
    • stringenumcommonoptional

      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
  • stringcommonoptional

    consistency

    Sets the write consistency for the point for InfluxDB 1.

    • No default
    • View examples
  • stringcommonrequired

    database

    Sets the target database for the write into InfluxDB 1.

    • No default
    • View examples
  • tableoptional

    encoding

    Configures the encoding specific sink behavior.

    • [string]optional

      except_fields

      Prevent the sink from encoding the specified labels.

      • No default
      • View examples
    • [string]optional

      only_fields

      Limit the sink to only encoding the specified labels.

      • No default
      • View examples
    • stringenumoptional

      timestamp_format

      How to format event timestamps.

      • Default: "rfc3339"
      • Enum, must be one of: "rfc3339" "unix"
      • View examples
  • stringcommonrequired

    endpoint

    InfluxDB endpoint to send metrics to.

    • No default
    • View examples
  • boolcommonoptional

    healthcheck

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

    • Default: true
    • View examples
  • stringcommonrequired

    namespace

    A prefix that will be added to all metric names.

    • No default
    • View examples
  • stringcommonrequired

    org

    Specifies the destination organization for writes into InfluxDB 2.

    • No default
    • View examples
  • stringcommonoptional

    password

    Sets the password for authentication if you’ve enabled authentication for the write into InfluxDB 1.

    • No default
    • View examples
  • tableoptional

    request

    Configures the sink request behavior.

    • uint (requests)commonoptional

      in_flight_limit

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

      • Default: 5 (requests)
    • uint (seconds)commonoptional

      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)
    • uintcommonoptional

      rate_limit_num

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

      • Default: 5
    • uintoptional

      retry_attempts

      The maximum number of retries to make for failed requests. The default, for all intents and purposes, represents an infinite number of retries. See Retry Policy for more info.

      • Default: -1
    • uint (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)
    • uint (seconds)optional

      retry_max_duration_secs

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

      • Default: 10 (seconds)
    • uint (seconds)commonoptional

      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)
  • stringcommonoptional

    retention_policy_name

    Sets the target retention policy for the write into InfluxDB 1.

    • No default
    • View examples
  • [string]optional

    tags

    A set of additional fields that will be attached to each LineProtocol as a tag. Note: If the set of tag values has high cardinality this also increase cardinality in InfluxDB. See Mapping Log Event into Line Protocol for more info.

    • No default
    • View examples
  • stringcommonrequired

    token

    Authentication token for InfluxDB 2.

    • No default
    • View examples
  • stringcommonoptional

    username

    Sets the username for authentication if you’ve enabled authentication for the write into InfluxDB 1.

    • No default
    • View examples

How It Works

Buffers & Batches

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

Mapping Log Event into Line Protocol

InfluxDB uses line protocol to write data points. It is a text-based format that provides the measurement, tag set, field set, and timestamp of a data point.

A Log Event event contains an arbitrary set of fields (key/value pairs) that describe the event.

The following matrix outlines how Log Event fields are mapped into InfluxDB Line Protocol:

FieldLine Protocol
hosttag
messagefield
source_typetag
timestamptimestamp
[custom-key]field

The default behaviour could be overridden by a tags configuration.

Mapping example

The following example shows how is Log Event mapped into Line Protocol:

Log Event
{
"host": "my.host.com",
"message": "<13>Feb 13 20:07:26 74794bfb6795 root[8539]: i am foobar",
"timestamp": "2019-11-01T21:15:47+00:00",
"custom_field": "custom_value"
}
Line Protocol
ns.vector,host=my.host.com,metric_type=logs custom_field="custom_value",message="<13>Feb 13 20:07:26 74794bfb6795 root[8539]: i am foobar" 1572642947000000000

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 issue.

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.