series_fill_const function fills missing values (nulls) in a numeric dynamic array (series) with a specified constant value. This function is useful for handling gaps in time series data where you want to replace missing data points with a known default value.
You can use series_fill_const when you have time series data with missing values and want to fill gaps with a specific constant value, such as zero, a default threshold, or a neutral value. This is particularly useful when missing values represent a specific state (like no activity, default configuration, or baseline values). Typical applications include financial data analysis, sensor data processing, and performance monitoring where a specific default value is meaningful.
For users of other query languages
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
Splunk SPL users
In Splunk SPL, filling missing values with constants is typically done with the
fillnull command or eval expressions using conditional logic. To fill arrays with constants, you usually need to expand arrays and apply the transformation row by row. In APL, series_fill_const works directly on dynamic arrays, making it efficient for series-wide constant filling.ANSI SQL users
ANSI SQL users
In SQL, filling missing values with constants is typically done with
COALESCE() or ISNULL() functions, but these only work on single values, not arrays. To fill array elements with constants, you usually need to unnest arrays and apply the function row by row. In APL, series_fill_const eliminates this complexity by directly replacing null values with a constant in arrays.Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | A dynamic array of numeric values that may contain null values. |
constant_value | numeric | The constant value to use for filling null values. |
Returns
A dynamic array where null values are replaced with the specified constant value.Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
In log analysis, you can use Run in PlaygroundOutput
This query fills missing request durations with 0, useful for representing periods of no activity or baseline performance.
series_fill_const to fill missing request duration data with a default value like 0, which might represent no activity or baseline performance.Query| id | durations | filled_durations |
|---|---|---|
| u123 | [null, 150, null, 200] | [0, 150, 0, 200] |
| u456 | [100, null, null, 300] | [100, 0, 0, 300] |
List of related functions
- series_fill_forward: Fills missing values by propagating the first known value forward. Use when you want to use the earliest available value to fill gaps.
- series_fill_backward: Fills missing values by propagating the last known value backward. Use when you want to use the most recent available value to fill gaps.
- series_fill_linear: Fills missing values using linear interpolation. Use when you want smooth transitions between known values.
- series_equals: Compares each element to a specified value. Use for identifying specific values after filling operations.
- series_greater: Returns elements greater than a specified value. Use for threshold analysis after filling missing data.