series_sum
This page explains how to use the series_sum function in APL.
The series_sum function in APL calculates the total of all numeric elements in a dynamic array. You use it when you have a series of values and you want to condense them into a single aggregate number. For example, if you create arrays of request durations or span times, series_sum lets you quickly compute the total across each series.
This function is useful in scenarios such as:
- Aggregating request latencies across sessions or users.
- Summing the duration of spans in distributed traces.
- Calculating total counts or values across arrays in security log analysis.
Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic (array) | The array of numeric values to sum. |
Returns
A real value representing the sum of all numeric elements in the array. If the array is empty, the function returns 0.
Use case examples
When you want to calculate the total request duration per user across multiple requests.
Query
Output
| id | durations | total_duration |
|---|---|---|
| u123 | [120, 300, 50] | 470 |
| u456 | [200, 150] | 350 |
This query collects request durations for each user, creates an array, and then sums the array to compute the total request time per user.
When you want to compute the total span duration per service within a trace.
Query
Output
| service.name | trace_id | durations | total_span_duration |
|---|---|---|---|
| frontend | t123 | [00:00:01.2000000, 00:00:02] | 00:00:03.2000000 |
| checkoutservice | t456 | [00:00:00.5000000] | 00:00:00.5000000 |
This query groups spans by service and trace, collects the span durations, and computes the total execution time of spans.
When you want to evaluate the total request duration for each HTTP status code.
Query
Output
| status | durations | total_duration |
|---|---|---|
| 200 | [100, 300, 50] | 450 |
| 500 | [250, 400] | 650 |
This query aggregates request durations for each HTTP status code, then sums them to provide insight into the total duration of successful vs. failed requests.
List of related functions
- series_abs: Returns the absolute value of each element in an array. Use it to normalize negative values in arrays.
- series_acos: Computes the arccosine of each element in an array. Use when you want the inverse cosine.
- series_atan: Computes the arctangent of each element in an array. Use when you want the inverse tangent.
- series_cos: Returns the cosine of each element in an array. Use it when analyzing cyclical data with a phase shift.
- series_tan: Returns the tangent of each element in an array. Use it when you want to transform arrays with tangent-based periodicity.