This page explains how to use the sum aggregation function in APL.
The sum
aggregation in APL is used to compute the total sum of a specific numeric field in a dataset. This aggregation is useful when you want to find the cumulative value for a certain metric, such as the total duration of requests, total sales revenue, or any other numeric field that can be summed.
You can use the sum
aggregation in a wide range of scenarios, such as analyzing log data, monitoring traces, or examining security logs. It is particularly helpful when you want to get a quick overview of your data in terms of totals or cumulative statistics.
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk SPL users
In Splunk, you use the sum
function in combination with the stats
command to aggregate data. In APL, the sum
aggregation works similarly but is structured differently in terms of syntax.
ANSI SQL users
In ANSI SQL, the SUM
function is commonly used with the GROUP BY
clause to aggregate data by a specific field. In APL, the sum
function works similarly but can be used without requiring a GROUP BY
clause for simple summations.
<new_column_name>
: (Optional) The name you want to assign to the resulting column that contains the sum.<numeric_field>
: The field in your dataset that contains the numeric values you want to sum.The sum
aggregation returns a single row with the sum of the specified numeric field. If used with a by
clause, it returns multiple rows with the sum per group.
The sum
aggregation can be used to calculate the total request duration in an HTTP log dataset.
Query
Output
total_duration |
---|
123456 |
This query calculates the total request duration across all HTTP requests in the dataset.
The sum
aggregation can be used to calculate the total request duration in an HTTP log dataset.
Query
Output
total_duration |
---|
123456 |
This query calculates the total request duration across all HTTP requests in the dataset.
The sum
aggregation can be applied to OpenTelemetry traces to calculate the total span duration.
Query
Output
total_duration |
---|
7890 |
This query calculates the total duration of all spans in the dataset.
You can use the sum
aggregation to calculate the total number of requests based on a specific HTTP status in security logs.
Query
Output
request_count |
---|
500 |
This query counts the total number of successful requests (status 200) in the dataset.
count
when you want to count the number of rows, not aggregate numeric values.avg
when you need to find the mean instead of the total sum.min
when you’re interested in the lowest value.max
when you’re interested in the highest value.sumif
when you only want to sum values that meet a specific condition.This page explains how to use the sum aggregation function in APL.
The sum
aggregation in APL is used to compute the total sum of a specific numeric field in a dataset. This aggregation is useful when you want to find the cumulative value for a certain metric, such as the total duration of requests, total sales revenue, or any other numeric field that can be summed.
You can use the sum
aggregation in a wide range of scenarios, such as analyzing log data, monitoring traces, or examining security logs. It is particularly helpful when you want to get a quick overview of your data in terms of totals or cumulative statistics.
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk SPL users
In Splunk, you use the sum
function in combination with the stats
command to aggregate data. In APL, the sum
aggregation works similarly but is structured differently in terms of syntax.
ANSI SQL users
In ANSI SQL, the SUM
function is commonly used with the GROUP BY
clause to aggregate data by a specific field. In APL, the sum
function works similarly but can be used without requiring a GROUP BY
clause for simple summations.
<new_column_name>
: (Optional) The name you want to assign to the resulting column that contains the sum.<numeric_field>
: The field in your dataset that contains the numeric values you want to sum.The sum
aggregation returns a single row with the sum of the specified numeric field. If used with a by
clause, it returns multiple rows with the sum per group.
The sum
aggregation can be used to calculate the total request duration in an HTTP log dataset.
Query
Output
total_duration |
---|
123456 |
This query calculates the total request duration across all HTTP requests in the dataset.
The sum
aggregation can be used to calculate the total request duration in an HTTP log dataset.
Query
Output
total_duration |
---|
123456 |
This query calculates the total request duration across all HTTP requests in the dataset.
The sum
aggregation can be applied to OpenTelemetry traces to calculate the total span duration.
Query
Output
total_duration |
---|
7890 |
This query calculates the total duration of all spans in the dataset.
You can use the sum
aggregation to calculate the total number of requests based on a specific HTTP status in security logs.
Query
Output
request_count |
---|
500 |
This query counts the total number of successful requests (status 200) in the dataset.
count
when you want to count the number of rows, not aggregate numeric values.avg
when you need to find the mean instead of the total sum.min
when you’re interested in the lowest value.max
when you’re interested in the highest value.sumif
when you only want to sum values that meet a specific condition.