Math Expressions
You can use general mathematical expressions on numerical data extracted from log lines.
Syntax
| expression [as <field>]
Rules
- The term "expression" is evaluated as a mathematical expression in the context of existing fields.
- Parentheses can be used to group operations.
- The ternary operator is supported so you can use
"condition ? value_if_true : value_if_false"
. - Supported mathematical operators
+, -, *, /, %
Examples
- Boolean expression tests like:
disk > 0.8 ? 1 : 0 as overcapacity
- Math function calls like:
min((fps / 10 + 1) * 10, 70) as bucket
- Assuming x = 1, 2, then
ceil(sqrt(x*x + y*y)) as d
should result in d = 2.0
Java Math Class
Sumo Logic does not officially support all of Java's Math class functions.
The Sumo Logic Java library includes the Math class functions, though they are not documented.
The following example uses the pow()
function:
| 10 as number | pow(number, 10) as newnumber
To reference Java's Math class functions, see Oracle's Math documentation.
Guide Contents
In this section, we'll introduce the following concepts:
📄️ abs
The absolute function calculates the absolute value of x.
📄️ acos
Returns the inverse cosine of the argument.
📄️ asin
Returns the inverse sine of the argument.
📄️ atan
Returns the inverse tangent of the argument.
📄️ atan2
Returns the four-quadrant inverse tangent of the two arguments b and c.
📄️ cbrt
The cube root function returns the cube root value of x.
📄️ ceil
The ceil operator rounds up a field value to the nearest integer value.
📄️ cos
Cosine of argument in radians.
📄️ cosh
Hyperbolic cosine of argument in radians.
📄️ exp
The exponent function returns Euler's number e raised to the power of x.
📄️ expm1
The expm1 function returns value of x in exp(x)-1, compensating for the roundoff in exp(x).
📄️ floor
The floor function rounds down to the largest previous integer value. Returns the largest integer not greater than x.
📄️ hypot
Returns the square root of the sum of an array of squares.
📄️ isNaN, isInfinity
The isNaN and isInfinity operators check a numeric string and return a boolean value.
📄️ log
The logarithm function returns the natural logarithm of x.
📄️ log10
The log10 function returns the base 10 logarithm of x.
📄️ log1p
The log1p function computes log(1+x) accurately for small values of x.
📄️ round
The round function returns the closest integer to x.
📄️ sin
Sine of argument in radians.
📄️ sinh Function
Hyperbolic sine of argument in radians.
📄️ sqrt
The square root function returns the square root value of x.
📄️ tan
Tangent of argument in radians.
📄️ tanh
Hyperbolic tangent of argument in radians.
📄️ toDegrees
Converts angles from radians to degrees.
📄️ toRadians
Converts angles from degrees to radians.