$ streams / web / transform
Vector Remap Language transforms at your ingest endpoint
Paste the source of a Vector remap transform into a stream. Send2Bucket runs it on every record it accepts, before delivery to your bucket or table, with no collector to deploy.
- [ok] 25 ms of run time per record
- [ok] events, logs, spans and metrics
- [ok] on every plan, Free included
if .level == "debug" { abort }
del(.email)
if exists(.user_id) { .user_id = sha2(string!(.user_id)) }
parsed, err = parse_json(.payload)
if err == null { .payload = parsed }
.cents = to_int(.cents) ?? 0sample events
{"cents":"1250","email":"ada@example.com","event":"order.paid","level":"info","user_id":"u_1042"}
{"event":"healthcheck","level":"debug"}
{"email":"lin@example.com","event":"signup","level":"info","payload":"{\"plan\":\"pro\",\"seats\":3}","user_id":"u_1043"}2 kept · 1 dropped
kept{"cents":1250,"event":"order.paid","level":"info","user_id":"14443145561cfb947e27cf08cbbafff3f24643a3016539bc788c411692ae680c"} dropped{"event":"healthcheck","level":"debug"} kept{"cents":0,"event":"signup","level":"info","payload":{"plan":"pro","seats":3},"user_id":"a5d75cc44e145db41b640174e8a503346a4b8fc8a9ac566533f4a63bf593c401"}
the same source in both places
Same language, no collector
Send2Bucket compiles the program with vrl 0.39, the open-source library Vector is built on. The source moves over; the Vector config around it does not.
[transforms.redact]
type = "remap"
inputs = ["app_events"]
source = '''
del(.email)
if exists(.user_id) { .user_id = sha2(string!(.user_id)) }
'''
del(.email)
if exists(.user_id) { .user_id = sha2(string!(.user_id)) }where the program runs
Four steps between your request and your bucket.
- 1. accepted
The request is checked as you sent it.
request{"cents":"1250","email":"ada@example.com","event":"order.paid","level":"info","user_id":"u_1042"} {"event":"healthcheck","level":"debug"} {"email":"lin@example.com","event":"signup","level":"info","payload":"{\"plan\":\"pro\",\"seats\":3}","user_id":"u_1043"} - 2. aggregation rules
Aggregation rules count records as they arrived, before any program changes them.
rules read{"cents":"1250","email":"ada@example.com","event":"order.paid","level":"info","user_id":"u_1042"} {"event":"healthcheck","level":"debug"} {"email":"lin@example.com","event":"signup","level":"info","payload":"{\"plan\":\"pro\",\"seats\":3}","user_id":"u_1043"} - 3. transform
The program runs on each record kept for raw delivery.
programif .level == "debug" { abort } del(.email) if exists(.user_id) { .user_id = sha2(string!(.user_id)) } parsed, err = parse_json(.payload) if err == null { .payload = parsed } .cents = to_int(.cents) ?? 0 - 4. delivered
Kept records join the batch for your bucket or table and are metered as the program left them; dropped ones never leave.
batch{"cents":1250,"event":"order.paid","level":"info","user_id":"14443145561cfb947e27cf08cbbafff3f24643a3016539bc788c411692ae680c"} {"cents":0,"event":"signup","level":"info","payload":{"plan":"pro","seats":3},"user_id":"a5d75cc44e145db41b640174e8a503346a4b8fc8a9ac566533f4a63bf593c401"}
what differs from a remap transform
The language is the same; the record, its context and its outcomes are Send2Bucket's.
what the program sees
| path | holds | writable |
|---|---|---|
. | the record's data: the event as sent, or the OpenTelemetry JSON of the log record, span or metric | yes |
%signal | event, log, span or metric | no effect |
%resource | an OpenTelemetry record's resource; absent for events and log drains | yes |
%scope | an OpenTelemetry record's instrumentation scope | yes |
outcomes and stream stats
| the program | Send2Bucket delivers | stream stats |
|---|---|---|
| ends normally | the record as the program left it | no change |
calls abort | nothing: the record is dropped | transform_dropped +1 |
| fails on the record | the record as it arrived | transform_failed +1 |
| runs past 25 ms on it | the record as it arrived | transform_failed +1 |
limits of a program
What a program can use, and the few things it cannot.
- [ok] one program per stream, up to 16 KiB
- [ok] 25 ms of run time per record, not counting decoding and encoding it
- [--] no network, environment or host functions, and no
parse_grok,parse_groksorlog - [--] numbers outside 64-bit integers and floats are rounded
- [--] aggregate rows are not transformed
frequently asked questions
What is a stream transform?
A Vector Remap Language program that Send2Bucket runs on each record of a stream before delivery. It can rewrite, redact, parse or drop records, so your bucket or table holds the shape you query.
Can I paste the source of a Vector remap transform?
Yes, when it uses only the functions Send2Bucket includes. Check its paths: the root is the record’s data as Send2Bucket delivers it, and OpenTelemetry context is in %resource and %scope, not in the fields a Vector source adds.
Which records does it run on?
Every record a stream keeps for raw delivery: JSON events, log drain records, and OpenTelemetry logs, spans and metrics. Aggregation rules read records as they arrived, before the transform runs, and aggregate rows are not transformed.
What happens when the program fails on a record?
The record is delivered as it arrived and counted as failed in the stream’s stats. The same happens when the program runs longer than 25 ms on one record. A record the program calls abort on is dropped and counted as dropped.
Does dropping records lower my bill?
Yes. Usage is counted on each record as the transform leaves it: a dropped record is not counted, and a shrunk record counts at its new size.
Which functions can a program use?
The Vector Remap Language standard library without its network, environment and host functions (such as http_request, dns_lookup, get_env_var and get_hostname), and without parse_grok, parse_groks and log.
Which plans include transforms?
Every plan, Free included. Setting a transform through the Management API needs Pro or Team, like the rest of that API.