Overview
Theremap transform is Vector’s most powerful data processing component. It uses VRL (Vector Remap Language) to modify observability data as it passes through your topology. VRL is a purpose-built language designed for transforming observability data safely and efficiently.
Key Features:
- Process logs, metrics, and traces
- Full-featured scripting with 100+ built-in functions
- Type-safe with compile-time checking
- High performance with compiled execution
- Error handling with multiple strategies
- Supports external enrichment tables
Configuration
The VRL program to execute for each event. Required if
file is not specified.File path to a VRL program. Required if
source is not specified.If a relative path is provided, its root is the current working directory.Array of file paths to VRL programs that will be executed in order.
Drop any event that encounters an error during processing.When
false, events that error are passed through unchanged. When true, errored events are dropped entirely (unless reroute_dropped is enabled).Drop any event that is manually aborted during processing.If a VRL program calls
abort, this controls whether the original event is sent downstream or dropped.Reroute dropped events to a named output instead of discarding them.When enabled, dropped events are sent to a special output named
dropped with metadata about why they were dropped.How to expose metric tag values in VRL.
single: Tags are single strings (last value wins)full: Tags are arrays of strings or null values
Timezone for timestamp conversions without explicit timezone.Overrides the global timezone setting. Use any TZ database name or
local for system time.Inputs
List of upstream component IDs.
Outputs
The remap transform has one default output and optionally adropped output:
- Default output: Successfully processed events
droppedoutput: Events dropped due to errors or aborts (whenreroute_dropped = true)
metadata.dropped.reason: “error” or “abort”metadata.dropped.message: Error messagemetadata.dropped.component_id: Component that dropped the eventmetadata.dropped.component_type: “remap”metadata.dropped.component_kind: “transform”
Examples
Basic Field Manipulation
Parse JSON Logs
Type Conversions and Validation
Conditional Processing
Structured Data Parsing
Data Enrichment
Error Handling with Rerouting
Multi-line Log Assembly
Modify Metrics
Using External Files
/etc/vector/transforms/parse_logs.vrl:
VRL Language Features
Vector Remap Language provides:Data Types
- String, Integer, Float, Boolean
- Timestamp, Duration, Regex
- Array, Object (map)
- Null
Operators
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,>,<,>=,<= - Logical:
&&,||,! - Null coalescing:
?? - Error coalescing:
!(fallible suffix)
Built-in Functions
String manipulation:upcase, downcase, trim, split, replace, strip_whitespace
Parsing: parse_json, parse_csv, parse_regex, parse_timestamp, parse_duration
Type conversion: to_int, to_float, to_bool, to_string, to_timestamp
Encoding: encode_base64, decode_base64, encode_json, sha1, md5
Array/Object: length, contains, keys, values, push, flatten
Date/Time: now, format_timestamp, parse_timestamp
Utility: assert, assert_eq, abort, log, get_hostname, get_env_var
View complete VRL function reference →
Error Handling
VRL has two types of operations:Infallible Operations
Operations that cannot fail:Fallible Operations
Operations that may fail must use! or ? suffix:
Performance Tips
Compile Once, Run Many
VRL programs are compiled once at startup. Complex transformations have minimal runtime overhead.Use Infallible Operations
Infallible operations are faster than fallible ones. Use them when possible:Minimize Field Access
Store frequently accessed fields in variables:Use Appropriate Functions
Choose the right function for the job:Testing VRL
Use thevector vrl command to test VRL programs:
Troubleshooting
Compilation Errors
VRL checks types at compile time. Common errors:- Type mismatch: Ensure operations match field types
- Missing
!suffix: Fallible operations need!or error handling - Undefined fields: Check field existence with
exists()first
Runtime Errors
Whendrop_on_error = false, runtime errors pass through the original event. Enable reroute_dropped to debug:
Performance Issues
If remap is a bottleneck:- Enable
component_received_events_totalmetrics - Check for expensive regex operations
- Minimize external enrichment lookups
- Consider splitting into multiple transforms