Splunk® Data Stream Processor

Function Reference

On April 3, 2023, Splunk Data Stream Processor reached 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.

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.

Aggregation

The following are scalar functions that you can use in the stats and aggregate with trigger streaming functions to perform calculations over data in a given time-window.

average(value)

Calculates the average (mean) of values in a time window.

Function Input
value: T
Function Output
double

SPL2 example

The following example returns the average (mean) "size" for each distinct "host".

When working in the SPL View, you can write the function by using the following syntax.

...| stats average(size) BY host, span(timestamp, 50s, 10s) |...; 

Alternatively, you can use named arguments.

...| stats average(value: size) BY host, span(timestamp, 50s, 10s) |...; 

count(value)

Returns the number of non-null values in a time window.

Function Input
value: any
Function Output
long

SPL2 example

Returns the count of the "status_code" field.

When working in the SPL View, you can write the function by using the following syntax.

...| stats count(status_code) by status_code, span(window_start, 5000ms, 1000ms, 1000ms) |...;

Alternatively, you can use named arguments.

...| stats count(value: status_code) by status_code, span(window_start, 5000ms, 1000ms, 1000ms) |...;

max(value)

Returns the maximum value in a time window.

Function Input
value: number
Function Output
number

SPL2 example

Returns the maximum value of the "time_taken" field.

When working in the SPL View, you can write the function by using the following syntax.

...| stats max(time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

Alternatively, you can use named arguments.

...| stats max(value: time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

mean(value)

Calculates the average (mean) of values in a time window.

Function Input
value: number
Function Output
double

SPL2 example

Returns the average value of the "time_taken" field.

When working in the SPL View, you can write the function by using the following syntax.

...| stats mean(time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

Alternatively, you can use named arguments.

...| stats mean(value: time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

min(value)

Returns the minimum value in a time window.

Function Input
value: number
Function Output
number

SPL2 example

Returns the minimum value of the "time_taken" field.

When working in the SPL View, you can write the function by using the following syntax.

...| stats min(time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

Alternatively, you can use named arguments.

...| stats min(value: time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

sum(value)

Returns the sum of values in a time window.

Function Input
value: number
Function Output
number

SPL2 example

Returns the sum of the "time_taken" field.

When working in the SPL View, you can write the function by using the following syntax.

...| stats sum(time_taken) by time_taken, span(timestamp, 50s, 10s) |...;

Alternatively, you can use named arguments.

...| stats sum(value: time_taken) by time_taken, span(timestamp, 50s, 10s) |...;
Last modified on 21 March, 2022
Overview of stats scalar functions  

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


Was this topic useful?







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