Throttle

status: beta egress: stream state: stateful
Rate limits one or more log streams to limit load on downstream services, or to enforce usage quotas on users.

Configuration

Example configurations

{
  "transforms": {
    "my_transform_id": {
      "type": "throttle",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "exclude": ".status_code != 200 && !includes([\"info\", \"debug\"], .severity)",
      "threshold": 100,
      "window_secs": 1
    }
  }
}
[transforms.my_transform_id]
type = "throttle"
inputs = [ "my-source-or-transform-id" ]
exclude = '.status_code != 200 && !includes(["info", "debug"], .severity)'
threshold = 100
window_secs = 1
---
transforms:
  my_transform_id:
    type: throttle
    inputs:
      - my-source-or-transform-id
    exclude: .status_code != 200 && !includes(["info", "debug"], .severity)
    threshold: 100
    window_secs: 1
{
  "transforms": {
    "my_transform_id": {
      "type": "throttle",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "exclude": ".status_code != 200 && !includes([\"info\", \"debug\"], .severity)",
      "key_field": "message",
      "threshold": 100,
      "window_secs": 1
    }
  }
}
[transforms.my_transform_id]
type = "throttle"
inputs = [ "my-source-or-transform-id" ]
exclude = '.status_code != 200 && !includes(["info", "debug"], .severity)'
key_field = "message"
threshold = 100
window_secs = 1
---
transforms:
  my_transform_id:
    type: throttle
    inputs:
      - my-source-or-transform-id
    exclude: .status_code != 200 && !includes(["info", "debug"], .severity)
    key_field: message
    threshold: 100
    window_secs: 1

exclude

common optional string remap_boolean_expression
The set of logical conditions to exclude events from rate limiting.
Examples
".status_code != 200 \u0026\u0026 !includes([\"info\", \"debug\"], .severity)"

inputs

required [string]

A list of upstream source or transform IDs. Wildcards (*) are supported.

See configuration for more info.

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

key_field

optional string template

The name of the log field whose value will be hashed to determine if the event should be rate limited.

Each unique key will create a buckets of related events to be rate limited separately. If left unspecified, or if the event doesn’t have key_field, the event be will not be rate limited separately.

Note: This parameter supports Vector's template syntax, which enables you to use dynamic per-event values.
Examples
"message"
"{{ hostname }}"

threshold

required uint

The number of events allowed for a given bucket per configured window.

Each unique key will have its own threshold.

Examples
100
10000

window_secs

required uint
The time frame in which the configured threshold is applied.
Examples
1
60
86400

Telemetry

Metrics

link

component_received_event_bytes_total

counter
The number of event bytes accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
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 data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_received_events_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
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 data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_sent_event_bytes_total

counter
The total number of event bytes emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.

component_sent_events_total

counter
The total number of events emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.

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.
reason required
The type of the error

events_in_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins. This metric is deprecated and will be removed in a future version. Use component_received_events_total instead.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
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 data originated.
peer_path optional
The pathname from which the data originated.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

events_out_total

counter
The total number of events emitted by this component. This metric is deprecated and will be removed in a future version. Use component_sent_events_total instead.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.

processed_bytes_total

counter
The number of bytes processed by the component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
container_name optional
The name of the container from which the bytes originate.
file optional
The file from which the bytes originate.
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 bytes originate.
peer_path optional
The pathname from which the bytes originate.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the bytes originate.
uri optional
The sanitized URI from which the bytes originate.

processed_events_total

counter
The total number of events processed by this component. This metric is deprecated in place of using component_received_events_total and component_sent_events_total metrics.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.

utilization

gauge
A ratio from 0 to 1 of the load on a component. A value of 0 would indicate a completely idle component that is simply waiting for input. A value of 1 would indicate a that is never idle. This value is updated every 5 seconds.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.

Examples

Rate limiting

Given this event...
[{"log":{"host":"host-1.hostname.com","message":"First message","timestamp":"2020-10-07T12:33:21.223543Z"}},{"log":{"host":"host-1.hostname.com","message":"Second message","timestamp":"2020-10-07T12:33:21.223543Z"}}]
...and this configuration...
[transforms.my_transform_id]
type = "throttle"
inputs = [ "my-source-or-transform-id" ]
threshold = 1
window = 60
---
transforms:
  my_transform_id:
    type: throttle
    inputs:
      - my-source-or-transform-id
    threshold: 1
    window: 60
{
  "transforms": {
    "my_transform_id": {
      "type": "throttle",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "threshold": 1,
      "window": 60
    }
  }
}
...this Vector event is produced:
[{"log":{"host":"host-1.hostname.com","message":"First message","timestamp":"2020-10-07T12:33:21.223543Z"}}]

How it works

Rate Limiting

The throttle transform will spread load across the configured window, ensuring that each bucket’s throughput averages out to the threshold per window. It utilizes a Generic Cell Rate Algorithm to rate limit the event stream.

Buckets

The throttle transform buckets events into rate limiters based on the provided key_field, or a single bucket if not provided. Each bucket is rate limited separately.

Quotas

Rate limiters use “cells” to determine if there is sufficient capacity for an event to successfully pass through a rate limiter. Each event passing through the transform consumes an available cell, if there is no available cell the event will be rate limited.

A rate limiter is created with a maximum number of cells equal to the threshold, and cells replenish at a rate of window divided by threshold. For example, a window of 60 with a threshold of 10 replenishes a cell every 6 seconds and allows a burst of up to 10 events.

Rate Limited Events

The rate limiter will allow up to threshold number of events through and drop any further events for that particular bucket when the rate limiter is at capacity. Any event passed when the rate limiter is at capacity will be discarded and tracked by an events_discarded_total metric tagged by the bucket’s key.

State

This component is stateful, meaning its behavior changes based on previous inputs (events). State is not preserved across restarts, therefore state-dependent behavior will reset between restarts and depend on the inputs (events) received since the most recent restart.