All DSP releases prior to DSP 1.4.0 use Gravity, a Kubernetes orchestrator, which has been announced end-of-life. We have replaced Gravity with an alternative component in DSP 1.4.0. Therefore, we will no longer provide support for versions of DSP prior to DSP 1.4.0 after July 1, 2023. We advise all of our customers to upgrade to DSP 1.4.0 in order to continue to receive full product support from Splunk.
Overview of evaluation scalar functions
Use evaluation scalar functions to evaluate an expression based on your records and return a result.
Functions that use evaluation scalar functions
You can use evaluation scalar functions with the Eval, Where, and Select streaming functions. See the following pages for more information, including examples of how evaluation scalar functions are used with these streaming functions:
You can also use evaluation scalar functions with any function that has an argument that accepts expressions. For example, the Send to Splunk HTTP Event Collector sink function has an index
argument that accepts expression<string>
values. When configuring this index
argument, you can specify an expression that uses evaluation scalar functions to resolve to a string value. For example, you can specify the following expression, which uses the map_get function to extract an index value from a map called attributes
, and then uses the cast function to cast the extracted value to the string data type: cast(map_get(attributes, "index"), "string")
Using evaluation scalar functions
- All functions that accept strings can accept either a literal string or any field.
- All functions that accept numbers can accept either literal numbers or any numeric field.
Specifying literal strings
For most evaluation scalar functions, when a string argument is expected you can specify either a literal string or a field. The literal string must be enclosed in double quotation marks. For example, if you have a field called name
which contains the names of your servers, and you want to append the literal string server
at the end of the name. You would specify this: name + "server"
.
Nested functions
You can specify a function as an argument to another function.
In the following example, the cidrmatch
function is used as the first argument in the if
function.
... | eval isLocal=if(cidrmatch("123.132.32.0/25",ip), "local", "not local");
Operators
The following tables list the basic mathematical operations that you can use with the evaluation scalar functions. For these operations to work, the values need to be valid for the type of operation. For example, with the exception of addition, arithmetic operations might not produce valid results if the values are not numerical. When concatenating values, Splunk software reads the values as strings, regardless of the value.
Arithmetic operators
Operators | Action | Description |
---|---|---|
+
|
Addition | Accepts two numbers and produces a number. |
-
|
Subtraction | Accepts two numbers and produces a number. |
*
|
Multiplication | Accepts two numbers and produces a number. |
/
|
Division | Accepts two numbers and produces a number. |
%
|
Modulo | Accepts two numbers and produces a number. |
Boolean operators
Operators | Action | Description |
---|---|---|
AND
|
Logical AND operator | Accepts two Boolean values and produces a Boolean. |
OR
|
Logical OR operator | Accepts two Boolean values and produces a Boolean. |
NOT
|
Logical NOT operator | Accepts one Boolean value and produces the inverse of the value. |
XOR
|
Exclusive OR operator | Accepts two Boolean values and produces a Boolean. |
IS NULL
|
NULL operator | Accepts a value and returns TRUE if the field value is NULL. |
IS NOT NULL
|
NULL operator | Accepts a value and returns TRUE if the field value is not NULL. |
<
|
Less than | Accepts two numbers and produces a Boolean. |
>
|
Greater than | Accepts two numbers and produces a Boolean. |
<=
|
Less than or equal to | Accepts two numbers or two strings and produces a Boolean. |
>=
|
Greater than or equal to | Accepts two numbers and produces a Boolean. |
!=
|
Not equal to | Accepts two numbers or two strings and produces a Boolean. |
= or ==
|
Equal to | In expressions, the = and == operators are synonymous. These operators compare the value of right side and left side of the expression. Returns 1 (true) if the sides are equal. Returns 0 (false) if the sides are not equal.
|
LIKE
|
Text pattern matching operator | Accepts two strings. For example string LIKE pattern . The pattern operator supports literal text, a percent ( % ) character for a wildcard, and an underscore ( _ ) character for a single character match.
For example, field |
IN
|
Matching operator | Accepts a value and a list, and checks whether the value is in the list. The list can either be a list literal or a field containing a list. For example string IN (1, 2, 3) or string IN (list_field) . Returns a Boolean.
|
Send data to null | Casting |
This documentation applies to the following versions of Splunk® Data Stream Processor: 1.3.0, 1.3.1, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6
Feedback submitted, thanks!