edit-icon download-icon

Syntax of if_assign in custom splitting

Last Updated: Jun 01, 2018

By default, ARMS supports the expression evaluation engine Aviator. You can complete logic control and value assignment with it when processing data.

Conditional statement if-else

Select Logic from the left-side operation pane of the Custom Splitting tab. The system provides such two types of logical judgment blocks as “if/else” and “if”, as shown in the following figure:

Node If Else

The following figure shows examples for some simple logical expressions. The user logs are as follows:

  1. 2017-01-09 16:02:49|ERROR|it is error...
  2. 2017-01-09 16:03:49|INFO|it is ok...
  3. 2017-01-09 16:03:49|INFO_1|it is ok...

After the log is split by vertical bars (|), some acquired fields are date, type, and message, respectively.

Example 1: If the field type is set to INFO, it indicates that this line of log is directly discarded.

If else example 1

Example 2: If the field type includes INFO, it indicates that this line of log is discarded.

If else example 2

Assign values

The following figure shows an example of a simple value assignment. The user logs are as follows:

  1. 2017-01-09 16:02:49|Songjiang District
  2. 2017-01-09 16:03:49|Pudong New Area
  3. 2017-01-09 16:03:49|Shangcheng District
  4. 2017-01-09 16:03:49|Xiacheng District

After splitting the log with vertical bars (|), we get the fileds date and region. If the field region is set to “Songjiang District” or “Pudong New Area”, a new field province (String type) is added with the value “Shanghai city”; if the field region is set to “Shangcheng District” or “Xiacheng District”, a new field province (String type) is added with the value “Hangzhou city”.

Custom Split Province

Built-in functions (From Aviator official documentation)

Aviator expression is an open source product. Click here to see the official documentation. Here are some common built-in functions:

Function Description
sysdate() Return the current date object java.util.Date
rand() Return a random number between 0 and 1 (Double type)
now() Return System.currentTimeMillis
long(v) Convert a value type into Long
double(v) Convert a value type into Double
date_to_string(date,format) Convert a Date object into a string in a specific format
string_to_date(source,format) Convert a string in a specific format into a Date object
string.contains(s1,s2) Judge if s1 contains s2, and return a Boolean value
string.length(s) Evaluate length of a string, and return a Long value
string.startsWith(s1,s2) Judge if s1 starts with s2, and return a Boolean value
string.endsWith(s1,s2) Judge if s1 ends with s2, and return a Boolean value
string.substring(s,begin[,end]) Cut out a substring s which is from begin to end. If the end is omitted, the substring s is from begin to the end of the string. This is the same as java.util.String.substring.
string.indexOf(s1,s2) The same as the method used for s1.indexOf(s2) in Java. That is, evaluate the start index location of s2 in s1. If it doesn’t exist, then it returns -1.
string.split(target,regex,[limit]) The same as the method used for String.split in Java
string.replace_first(s,regex,replacement) The same as the method used for String.replaceFirst in Java
string.replace_all(s,regex,replacement) The same as the method used for String.replaceAll in Java
math.abs(d) Evaluate the absolute value of d
math.sqrt(d) Evaluate the square root of d
math.pow(d1,d2) Evaluate d1 to the power of d2
math.log(d) Evaluate the natural logarithm of d
math.log10(d) Evaluate the base-10 logarithm of d
math.sin(d) Sine function
math.cos(d) Cosine function
math.tan(d) Tangent function
Thank you! We've received your feedback.