Configuring Jexl operators

Many lenses allow one to write a Jexl script as part of their configuration. Jexl is a friendly language offering a number of operators which can be applied to transform data (typically the payload fields ) or do comparison, and so on.

Here are a selection, there are further details at the Jexl GitHub page.


Use these operators to perform mathematical operations on values

Operation Symbol Example






3 + 47



4 - 31



3 * 824



15 / 43.75

Divide and Floor


15 // 43



23 % 21

Power of



Logical AND


true && truetrue

Logical OR



Use these expressions to compare two values, the Boolean results can be used for, for example filtering.

Operation Symbol Example



1 == 2false

Not Equal


1 != 2true

Greater Than


2 > 3false

Greater Than or Equal


3 >= 3true

Less Than


2 < 3true

Less Than or Equal


2 ⇐ 4true

Element in array or string


"cat" in ["cat", "dog", "mouse"]true

Conditional Operators.

Conditional operators return the second or third expression based on the result of the first expression. If the first expression ("Bob" in ["Bob", "Mary"] below) return true, "Yes" is returned. If it returns false, "No" is returned.

Example Result

"Bob" in ["Bob", "Mary"] ? "Yes" : "No"



Access variables in the payload with dot notation or by using brackets, for example:

  name: {
    first: 'John'
    last: 'Smith'
  age: 55,
  colleagues: [
  teammate: 2
Example Result





name['la' + 'st']


Collection filtering.

Arrays of objects (Collections) can be filtered by including a filter expression in brackets. Properties of each collection can be referenced by prefixing them with a leading dot. The result is an array of objects for which the filter returns a truthy value.

  users: [
    { first: 'John', last: 'Smith', age: 20},
    { first: 'Mary', last: 'Jones', age: 46},
    { first: 'Ted', last: 'Cotter', age: 16},
    { first: 'Bob', last: 'White', age: 66}
  adult: 21
Example Result

users[.last == 'Jones']

[\{ first: 'Mary', last: 'Jones', age: 46}]

users[.age < adult]

[\{ first: 'John', last: 'Smith', age: 20}, first: 'Ted', last: 'Cotter', age: 16}]

users[first == 'John'].last


Lens Expression Functions

In addition to the general Jexl parsing functionality, Siren Investigate also exposes a number of JavaScript-like functions for use in Lens Expressions. Payload values (or the results from earlier parsing) are piped into the function using the | character. These values become the val parameter for the functions below - meaning the val does not need to be added in the () after the function name. In some cases, this value is all that is needed by the function and some functions require extra parameters.

Some functions require string inputs and some require integer or floating-point inputs

Table 1. String Lens Expressions
Function Example Explanation

split(val, delimiter[, limit)]

payload.IP | split('.', 3)

Splits an IP address by the '.' and returns the first 3 entries as an array

endsWith(val, substring[, length)] | endsWith('smith', 10)

Returns true if val ends with substring, if length is added, that number of characters from the beginning of val is checked.

startsWith(val, substring[, position)] | startsWith('smith', 10)

Returns true if val begins with substring, if position is added, the substring from that position to the end of val is checked.

indexOf(val, substring[, length)] | indexOf('smith', 10)

Returns the position of the first character of substring if val contains substring, if length is added, val is checked from that position.

upper(val) | upper

Returns val in upper case.

lower(val) | lower

Returns val in lower case.

indexOf(val, start, end) | substring(5, 10)

Returns the string within val found between start and end.

replace(val, substring, newSubString) | replace('smith', 'jones')

Replaces substring with newSubString in val.

Table 2. Number lens Expressions
Function Example Explanation


payload.range | round

Returns val rounded to the nearest integer.


payload.range | trunc

Returns the integer part of val.


payload.range | sqrt

Returns √val.


payload.range | sign

Returns 1 if val is positive, -1 if val is negative or 0 if val equals 0.


payload.price | ceil

Returns the nearest integer greater than val


payload.price | floor

Returns the nearest integer less than val


payload.temperature_change | abs

Returns the absolute value for a Number or 0 if the number is null


payload.difference | exp

Returns ℯval


payload.difference | log

Returns the natural logarithm of val, for example ln(val)


payload.range | random

Returns val multiplied by a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive).