Overview
VRL is an expression-oriented language where every construct evaluates to a value. This page documents all VRL syntax, expressions, and operators.Program Structure
A VRL program consists of one or more expressions, each ending with a newline or semicolon:Comments
VRL supports single-line comments starting with#:
Literal Expressions
Literals represent fixed values in your code.String Literals
Interpreted Strings
Double-quoted strings with escape sequences and interpolation:Raw Strings
Raw strings withs'...' syntax - no escape processing:
Escape Sequences
Supported escape sequences in interpreted strings:\n- Newline\r- Carriage return\t- Tab\\- Backslash\"- Double quote\'- Single quote\0- Null character\{- Literal brace (escapes interpolation)\u{7FFF}- Unicode code point (up to 6 hex digits)
Integer Literals
Whole numbers:Float Literals
Floating-point numbers:Boolean Literals
True or false values:Null Literal
Absence of a value:Array Literals
Ordered collections:Object Literals
Key-value maps:Timestamp Literals
RFC 3339 timestamps witht'...' syntax:
Regular Expression Literals
Regex patterns withr'...' syntax:
Path Expressions
Paths access and modify event fields.Field Access
Access event fields with dot notation:Array Indexing
Access array elements by index (0-based):Dynamic Field Access
Use bracket notation for dynamic or special keys:Path Assignment
Assign values to paths:Variable Expressions
Variables store intermediate values.Variable Assignment
Variable Naming
Variable names must:- Start with a letter or underscore
- Contain only letters, numbers, and underscores
- Not be a reserved keyword
Variable Scope
Variables are scoped to the VRL program and to blocks:Arithmetic Expressions
Arithmetic operators perform mathematical operations.Addition
Subtraction
Multiplication
Division
Float division - always returns float:Integer Division
Returns integer, truncating remainder:Modulo
Returns remainder:Operator Precedence
From highest to lowest:()- Parentheses*,/,//,%- Multiplicative+,-- Additive
Comparison Expressions
Comparison operators compare values and return boolean:Equality
Inequality
Greater Than
Greater Than or Equal
Less Than
Less Than or Equal
Type Comparison
Comparisons require compatible types:Logical Expressions
Logical operators combine boolean expressions.AND Operator
True only if both operands are true:OR Operator
True if either operand is true:NOT Operator
Negates boolean value:Short-Circuit Evaluation
Logical operators short-circuit:Operator Precedence
From highest to lowest:!- NOT&&- AND||- OR
Assignment Expressions
Assignment stores values in paths or variables.Simple Assignment
Merge Assignment
Merges objects:Coalescing Assignment
Assigns only if right side succeeds:Fallible Assignment with Error Capture
Capture errors when calling fallible functions:Chained Assignment
Coalesce Expression (??)
Provides fallback for null or error:Conditional Expressions (if)
Conditional branching:Basic If Expression
If-Else If-Else
If Without Else
If as Statement
Nested If
Block Expressions
Blocks group multiple expressions:Function Call Expressions
Call built-in functions:Index Expression
Access array elements or object fields:Abort Expression
Aborts event processing:Return Expression
Returns from program early:Iteration Expressions
VRL provides iteration through functions with closures.for_each Function
map_values Function
map_keys Function
filter Function
reduce Function
Closure Syntax
Closures are anonymous functions used with iteration:Operator Precedence Summary
From highest to lowest:()- Grouping[],.- Indexing, field access!- Logical NOT, function calls*,/,//,%- Multiplicative+,-- Additive==,!=,<,<=,>,>=- Comparison&&- Logical AND||- Logical OR??- Coalescing=,|=,??=- Assignment
Reserved Keywords
These words are reserved and cannot be used as identifiers:if,elsetrue,falsenullabortreturnfor,while,loop(reserved for future use)
Best Practices
Use Type Coercion Explicitly
Handle Fallible Operations
Check Existence Before Access
Use Meaningful Variable Names
Learn More
- VRL Overview - Introduction to VRL
- VRL Functions - Built-in function reference
- VRL Examples - Real-world examples