Sample

Sample events from an event stream based on supplied criteria and at a configurable rate

status: stable egress: stream state: stateless
Samples events at a configurable rate.

Configuration

Example configurations

{
  "transforms": {
    "my_transform_id": {
      "type": "sample",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "rate": 1500
    }
  }
}
[transforms.my_transform_id]
type = "sample"
inputs = [ "my-source-or-transform-id" ]
rate = 1_500
transforms:
  my_transform_id:
    type: sample
    inputs:
      - my-source-or-transform-id
    rate: 1500
{
  "transforms": {
    "my_transform_id": {
      "type": "sample",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "key_field": "message",
      "rate": 1500
    }
  }
}
[transforms.my_transform_id]
type = "sample"
inputs = [ "my-source-or-transform-id" ]
key_field = "message"
rate = 1_500
transforms:
  my_transform_id:
    type: sample
    inputs:
      - my-source-or-transform-id
    key_field: message
    rate: 1500

exclude

optional condition
A logical condition used to exclude events from sampling.

exclude.source

The text of the condition. The syntax of the condition depends on the value of type.

exclude.type

The type of condition to supply. See Available syntaxes below for a list of available types for this transform.

Available syntaxes

SyntaxDescriptionExample
vrlA Vector Remap Language (VRL) Boolean expression..status_code != 200 && !includes(["info", "debug"], .severity)
datadog_searchA Datadog Search query string.*stack
is_logWhether the incoming event is a log.
is_metricWhether the incoming event is a metric.
is_traceWhether the incoming event is a trace.

Shorthand for VRL

If you opt for the vrl syntax for this condition, you can set the condition as a string via the condition parameter, without needing to specify both a source and a type. The table below shows some examples:

Config formatExample
YAMLcondition: .status == 200
TOMLcondition = ".status == 200"
JSON"condition": ".status == 200"

Condition config examples

Standard VRL

exclude:
  type: "vrl"
  source: ".status == 500"
exclude = { type = "vrl", source = ".status == 500" }
"exclude": {
  "type": "vrl",
  "source": ".status == 500"
}
exclude:
  type: "datadog_search"
  source: "*stack"
exclude = { type = "datadog_search", source = "*stack" }
"exclude": {
  "type": "datadog_search",
  "source": "*stack"
}

VRL shorthand

exclude: ".status == 500"
exclude = ".status == 500"
"exclude": ".status == 500"

graph

optional object

Extra graph configuration

Configure output for component when generated with graph command

graph.node_attributes

optional object

Node attributes to add to this component’s node in resulting graph

They are added to the node as provided

graph.node_attributes.*
required string literal
A single graph node attribute in graphviz DOT language.
Examples
{
  "color": "red",
  "name": "Example Node",
  "width": "5.0"
}

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 literal

The name of the field whose value is hashed to determine if the event should be sampled.

Each unique value for the key creates a bucket of related events to be sampled together and the rate is applied to the buckets themselves to sample 1/N buckets. The overall rate of sampling may differ from the configured one if values in the field are not uniformly distributed. If left unspecified, or if the event doesn’t have key_field, then the event is sampled independently.

This can be useful to, for example, ensure that all logs for a given transaction are sampled together, but that overall 1/N transactions are sampled.

Examples
"message"

rate

required uint

The rate at which events are forwarded, expressed as 1/N.

For example, rate = 1500 means 1 out of every 1500 events are forwarded and the rest are dropped.

Examples
1500

Outputs

<component_id>

Default output stream of the component. Use this component’s ID as an input to downstream transforms and sinks.

Telemetry

Metrics

link

component_discarded_events_total

counter
The number of events dropped by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
intentional
True if the events were discarded intentionally, like a filter transform, or false if due to an error.
pid optional
The process ID of the Vector instance.

component_errors_total

counter
The total number of errors encountered by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
error_type
The type of the error
host optional
The hostname of the system Vector is running on.
pid optional
The process ID of the Vector instance.
stage
The stage within the component at which the error occurred.

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
The Vector component ID.
component_kind
The Vector component kind.
component_type
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 optional
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 optional
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_count

histogram

A histogram of the number of events passed in each internal batch in Vector’s internal topology.

Note that this is separate than sink-level batching. It is mostly useful for low level debugging performance issues in Vector due to small internal batches.

component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
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 optional
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 optional
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
The Vector component ID.
component_kind
The Vector component kind.
component_type
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 optional
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 optional
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
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
output optional
The specific output of the component.
pid optional
The process ID of the Vector instance.

component_sent_events_total

counter
The total number of events emitted by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
output optional
The specific output of the component.
pid optional
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
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
pid optional
The process ID of the Vector instance.

How it works

State

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