Summary
collect(<tsExpression1>, <tsExpression2> [, <tsExpression3>, ...])
Returns a tsExpression that is the combination of two or more tsExpressions.
Parameters
| Parameter | Description |
|---|---|
| tsExpressionN | A time-series expression that you want to include in the collection. |
Description
The collect() function returns a tsExpression that is the combination of two or more tsExpressions.
The returned expression includes a synthetic collect_<number> point tag, where <number> is the number of input expressions.
The collect() function is a convenience function that combines multiple expressions into a single expression. It does not operate on the time series described by the input expressions. For example, it does not create a single series from them.
Example
Assume you want the mean for the number of processes. You could calculate it explicitly:
(
lag(1w,${processes})+
lag(2w,${processes})+
lag(3w,${processes})+
lag(4w,${processes})+
lag(5w,${processes})
) / 5
The problem is, if there’s a holiday or other anomaly during one of those lags, the data are affected and the mean doesn’t tell you the complete story.
With collect() you can do a similar query but get the median instead of the mean. The median filters out anomalies and holidays:
percentile(50,collect(
lag(1w,${processes}),
lag(2w,${processes}),
lag(3w,${processes}),
lag(4w,${processes}),
lag(5w,${processes})
))
The following screen shot shows the second query, with the anomalies filtered out because we can use (percentile(50...)) to get the median instead of the mean.
