Operators
Boolean Operators
| Name | Description |
|---|---|
OR | Boolean OR, also ||. |
AND | Boolean AND, also &&. |
NOT | Boolean NOT, also !. |
Examples:
value > 90 && avg() > 50
tags.file_system LIKE '/opt/*' OR tags.file_system LIKE '/mnt/*'
tags.file_system NOT LIKE '/dev/*'
NOT tags.isEmpty()
Ternary Operator
| Name | Description |
|---|---|
? | Ternary conditional |
The ternary ? operator simplifies if/else syntax. The operator chooses one of the two options based on the boolean expression.
If the expression expr evaluates to true, the operator selects value1 option. Otherwise, value2 is chosen.
boolean expr ? value1 : value2
Examples:
tags.mount_point == '/' ? 90.0 : 75.0
// The above example is equivalent to:
if (tags.mount_point == '/') {
return 90.0;
} else {
return 75.0;
}
status >= 500 ? 'Server Error' : ((status >= 400) ? 'Client Error' : ((status >= 300) ? 'Redirect' : 'OK')))
Numeric Operators
| Name | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus |
=== | Equality |
!= | Inequality |
> | Greater than |
>= | Greater than or equal to |
< | Less than |
<= | Less than or equal to |
BETWEEN | n BETWEEN m AND pThe number n is between m and p (inclusive).m <= n <= p.Example: avg() BETWEEN 10 and 20. |
IN | Returns true if the number is contained in the numeric collection. |
Examples:
value*100 > 90
max() BETWEEN 80 and 100
value IN (0, 1, 12)
Text Operators
| Name | Description |
|---|---|
=== | Equality. The comparison is case-insensitive ('a' = 'A' returns true). |
!= | Not equal. The comparison is case-insensitive ('a' != 'A' returns false). |
BETWEEN | Returns true if the left operand string is ordered between lower and upper strings on the right.a BETWEEN b AND c.String a is ordered between b and c (inclusive) using lexicographical comparison.The comparison is case-sensitive. Example: timeStr BETWEEN '18:00' AND '18:04'. |
LIKE | Returns true if the left operand string matches the pattern on the right. The pattern can include regular characters and wildcards ? and *.The operator also accepts a collection of patterns in round brackets. |
IN | Returns true if the left operand string is contained in the string collection specified in parenthesis on the right. |
Examples:
entity = 'nurswgvml007'
entity IN ('nurswgvml007', 'nurswgvml010')
entity LIKE '*007'
tags.location LIKE ('NUR*', entity.tags.location)