Splunk® Data Stream Processor

Function Reference

Acrobat logo Download manual as PDF

Acrobat logo Download topic as PDF

Mathematical

abs(value)

Mathematical evaluation function that returns a number's absolute value. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
number
Function Output
number

SPL2 examples

Returns the absolute values of the numeric field number.

... | eval absnum=abs(number);

Alternatively, you can use named arguments. See SPL2 syntax for more details.

... | eval absnum=abs(value: number);

addition

For documentation on how to perform addition, see arithmetic operators.

ceil(value)

Mathematical evaluation function that rounds a number up to the next highest integer. Returns the result as a double. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
value: number
Function Output
double

SPL2 examples

The following examples return n=2.

...| eval n=ceil(1.9);

Alternatively, you can use named arguments. See SPL2 syntax for more details.

...| eval n=ceil(value: 1.9);

division

For documentation on how to perform division, see arithmetic operators.

exp(value)

Mathematical evaluation function that takes a number value and returns the exponential evalue as a double. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
number
Function Output
double

SPL2 example

Returns 2.718281828459045 as a double.

... | eval n=exp(1);

Alternatively, you can use named arguments. See SPL2 syntax for more details.

... | eval n=exp(value: 1);

floor(value)

Mathematical evaluation function that rounds a number down to the nearest integer. Returns the result as a double. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
number
Function Output
double

SPL2 examples

Returns 1 as a double.

... | eval n=floor(1.2);

Alternatively, you can use named arguments. See SPL2 syntax for more details.

... | eval n=floor(value: 1.2);

log(value, base)

This function takes either one or two numeric arguments and returns the logarithm of the first argument value using the second argument base as the base. If the second argument base is omitted, this function evaluates the logarithm of number value with base 10. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
value: number
base: number
Function Output
double

SPL2 example

Returns 4 as a double.

... | eval n=log(16,2);

Alternatively, you can use named arguments to list the arguments in any order. See SPL2 syntax for more details.

... | eval n=log(base: 2, value: 16);

ln(value)

Mathematical evaluation function that takes a number and returns its natural logarithm as a double. Returns null for invalid values. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
value: number
Function Output
double

SPL2 examples

Returns 0 as a double.

... | eval n=ln(1);

Alternatively, you can use named arguments. See SPL2 syntax for more details.

... | eval n=ln(value: 1);

modulo

For documentation on how to get the remainder of two values, see arithmetic operators.

multiplication

For documentation on how to perform multiplication, see arithmetic operators.

pi()

Mathematical evaluation function that takes no arguments, but returns the constant pi to 20 digits of precision. Use this scalar function with the eval or the filter streaming functions.

Function Input
null
Function Output
double

SPL2 example

Returns 3.14159265358979323846 as a double.

... | eval n=pi();

pow(base, exp)

Mathematical evaluation function that takes two numbers base and exp, and returns baseexp as a double. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
base: number
exp: number
Function Output
double

SPL2 examples

Returns 4 as a double.

... | eval n=pow(2,2);

Alternatively, you can use named arguments to list the arguments in any order. See SPL2 syntax for more details.

... | eval n=pow(exp: 2, base: 2);

randomint()

Mathematical evaluation function that takes no arguments, but returns a number ranging from 0 to 231-1 as an integer. Use this scalar function with the eval or the filter streaming functions.

Function Input
null
Function Output
integer

SPL2 example

Returns a random number between 0 and 231-1 as an integer.

... | eval n=randomint();

round(value)

Takes a numeric arguments value and returns the nearest whole number. Use this scalar function with the eval or the filter streaming functions.

Function Input
value: double
Function Output
double

SPL2 examples

Returns 3.0 as a double.

...| eval n=round(cast(2.555d, "double"));

Alternatively, you can use named arguments. See SPL2 syntax for more details.

...| eval n=round(value: cast(2.555d, "double"));

round(value, num_decimals)

Mathematical evaluation function that takes two numeric arguments, value and num_decimals, and returns value rounded to the amount of decimal places specified by num_decimals. Use this scalar function with the eval or the filter streaming functions.

Function Input
value: double
num_decimals: integer
Function Output
double

SPL2 examples Returns 2.56 as a double.

...| eval n=round(2.555, 2);

Alternatively, you can use named arguments to list the arguments in any order. See SPL2 syntax for more details.

...| eval n=round(num_decimals: 2, value: 2.555);

subtraction

For documentation on how to perform subtraction, see arithmetic operators.

sqrt(value)

Mathematical evaluation function that takes a number and returns its square root. Use this scalar function with the eval or the filter streaming functions. Numbers can be type int, long, float, or double.

Function Input
value: number
Function Output
double

SPL2 example

Returns 10 as a double.

... | eval n=sqrt(100);

Alternatively, you can use named arguments to list the arguments in any order. See SPL2 syntax for more details.

... | eval n=sqrt(value: 100);
Last modified on 10 November, 2020
PREVIOUS
Map
  NEXT
String manipulation

This documentation applies to the following versions of Splunk® Data Stream Processor: 1.2.0


Was this documentation topic helpful?

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters