Splunk® Data Stream Processor

Function Reference

Acrobat logo Download manual as PDF


On April 3, 2023, Splunk Data Stream Processor will reach its end of sale, and will reach its end of life on February 28, 2025. If you are an existing DSP customer, please reach out to your account team for more information.
This documentation does not apply to the most recent version of Splunk® Data Stream Processor. For documentation on the most recent version, go to the latest release.
Acrobat logo Download topic as PDF

Mathematical

abs

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 example

Returns the absolute values of the numeric field number.

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

ceiling

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
number
Function Output
double

SPL2 example

The following example returns n=2.

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

exponential

Mathematical evaluation function that takes a number X and returns the exponential eˣ 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);

floor

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 example

Returns 1 as a double.

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

logarithm

This function takes either one or two numeric arguments and returns the logarithm of the first argument X using the second argument Y as the base. If the second argument Y is omitted, this function evaluates the logarithm of number X 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
input: number
base: number
Function Output
double

SPL2 example

Returns 4 as a double.

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

natural logarithm

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
number
Function Output
double

SPL2 example

Returns 0 as a double.

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

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();

power of base

Mathematical evaluation function that takes two numeric arguments, X and Y, and returns XY 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 example

Returns 4 as a double.

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

random integer

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

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

Function Input
num_dec: integer
value: double
Function Output
double

SPL2 example

Returns 2.56 as a double.

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

round value

Mathematical evaluation function that takes a numeric argument X and returns X rounded to the nearest whole number. Use this scalar function with the eval or the filter streaming functions.

Function Input
double
Function Output
double

SPL2 example

Returns 3.0 as a double.

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

square root

Mathematical evaluation function that takes a number X 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
number
Function Output
double

SPL2 example

Returns 10 as a double.

... | eval n=sqrt(100);
Last modified on 05 August, 2020
PREVIOUS
Map
  NEXT
String manipulation

This documentation applies to the following versions of Splunk® Data Stream Processor: 1.1.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