filter
Input Stack:
|
⇨ | Output Stack:
|
Filter time series from a grouped expression based on a condition. The condition must evaluate to signal time series (boolean-like values) that determine which time series from the original expression should be included in the output. This is essential for focusing on specific subsets of data that meet certain criteria.
Parameters¶
- expr: The grouped time series expression to filter (typically from :by)
- condition: Signal time series indicating which series to keep (non-zero = keep, zero = exclude)
How It Works¶
- Evaluation: The condition expression is evaluated for each time series in the input
- Signal interpretation: Non-zero values in the condition signal mean "keep this series"
- Filtering: Only time series where the condition evaluates to non-zero are included
- Output: Returns the filtered subset with their original data
Examples¶
Suppress all time series (condition always evaluates to 0):
Before | After |
name,sps,:eq, (,nf.cluster,),:by | name,sps,:eq, (,nf.cluster,),:by, 0,:filter |
Manual filtering using statistics (verbose approach) - show only lines with average value between 5k and 20k:
Before | After |
name,sps,:eq, (,nf.cluster,),:by | name,sps,:eq, (,nf.cluster,),:by, :dup, avg,:stat, 5e3,:gt, :over, avg,:stat, 20e3,:lt, :and, :filter |
Simplified filtering using stat helpers (recommended approach) - same filter condition as above:
Before | After |
name,sps,:eq, (,nf.cluster,),:by | name,sps,:eq, (,nf.cluster,),:by, :stat-avg, 5e3,:gt, :stat-avg, 20e3,:lt, :and, :filter |
Stat Helper Integration¶
The most common filtering pattern uses summary statistics with helper operators that automatically substitute the input expression:
- :stat-avg - Filter by average values
- :stat-max - Filter by maximum values
- :stat-min - Filter by minimum values
- :stat-count - Filter by datapoint count
- :stat-total - Filter by sum of values
- :stat-last - Filter by most recent values
These helpers eliminate the need to manually duplicate the input expression in filtering conditions.