By default, ARMS supports the expression evaluation engine Aviator. You can complete logic control and value assignment with it when processing data.
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:
The following figure shows examples for some simple logical expressions. The user logs are as follows:
2017-01-09 16:02:49|ERROR|it is error...
2017-01-09 16:03:49|INFO|it is ok...
2017-01-09 16:03:49|INFO_1|it is ok...
After the log is split by vertical bars (|), some acquired fields are
Example 1: If the field
type is set to INFO, it indicates that this line of log is directly discarded.
Example 2: If the field
type includes INFO, it indicates that this line of log is discarded.
The following figure shows an example of a simple value assignment. The user logs are as follows:
2017-01-09 16:02:49|Songjiang District
2017-01-09 16:03:49|Pudong New Area
2017-01-09 16:03:49|Shangcheng District
2017-01-09 16:03:49|Xiacheng District
After splitting the log with vertical bars (|), we get the fileds
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”.
Aviator expression is an open source product. Click here to see the official documentation. Here are some common built-in functions:
|sysdate()||Return the current date object java.util.Date|
|rand()||Return a random number between 0 and 1 (Double type)|
|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|