Skip to main content

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:

icon

abs

Calculates the absolute value of x.

icon

acos

Returns the inverse cosine of the argument.

icon

asin

Returns the inverse sine of the argument.

icon

atan

Returns the inverse tangent of the argument.

icon

atan2

Returns the four-quadrant inverse tangent of the two arguments b and c.

icon

cbrt

The cube root function returns the cube root value of x.

icon

ceil

Rounds up a field value to the nearest integer value.

icon

cos

Cosine of argument in radians.

icon

cosh

Hyperbolic cosine of argument in radians.

icon

exp

The exponent function returns Euler's number e raised to the power of x.

icon

expm1

Returns a value of x in exp(x)-1, compensating for the roundoff in exp(x).

icon

floor

Rounds down to the largest previous integer value.

icon

hypot

Returns the square root of the sum of an array of squares.

icon

isNaN, isInfinity

These operators check a numeric string and return a boolean value.

icon

log

The logarithm function returns the natural logarithm of x.

icon

log10

The log10 function returns the base 10 logarithm of x.

icon

log1p

Computes log(1+x) accurately for small values of x.

icon

round

The round function returns the closest integer to x.

icon

sin

Sine of argument in radians.

icon

sinh

Hyperbolic sine of argument in radians.

icon

sqrt

The square root function returns the square root value of x.

icon

tan

Tangent of argument in radians.

icon

tanh

Hyperbolic tangent of argument in radians.

icon

toDegrees

Converts angles from radians to degrees.

icon

toRadians

Converts angles from degrees to radians.


Legal
Privacy Statement
Terms of Use

Copyright © 2023 by Sumo Logic, Inc.