avg
Average or mean aggregation operator. There are two variants of the :avg
operator.
Aggregation
Input Stack: |
⇨ |
Output Stack: |
A helper method that computes the average or mean from one or more time series using the
count aggregate to determine how many time series have data at an interval and
dividing the sum of the values by the count. This avoids issues where one or time series
are missing data at a specific time resulting in an artificially low average. E.g. the
expression:
name,ssCpuUser,:eq,
:avg
when matching against the sample data in the table below, the highlighted time series would be
included in the aggregate result:
Name | nf.app | nf.node | Data |
ssCpuUser |
alerttest |
i-0123 |
[1.0, 2.0, NaN] |
ssCpuSystem |
alerttest |
i-0123 |
[3.0, 4.0, 5.0] |
ssCpuUser |
nccp |
i-0abc |
[8.0, 7.0, 6.0] |
ssCpuSystem |
nccp |
i-0abc |
[6.0, 7.0, 8.0] |
numRequests |
nccp |
i-0abc |
[1.0, 2.0, 4.0] |
ssCpuUser |
api |
i-0456 |
[1.0, 2.0, 2.0] |
The values from the corresponding intervals will be aggregated. For the first interval using
the sample data above the values are 1.0
, 8.0
, and 1.0
. Each value other than NaN
contributes one to the average. This leads to a final result of:
Name | Data |
ssCpuUser |
[3.33, 3.66, 4.0] |
The only tags for the aggregated result are those that are matched exactly (:eq clause)
as part of the choosing criteria or are included in a group by.
Math
Input Stack: |
⇨ |
Output Stack: |
Compute the average of all the time series from the input expression. This is typically used when
there is a need to use some other aggregation for the grouping. Example:
Before | After |
| |
name,sps,:eq,
(,nf.cluster,),:by
| name,sps,:eq,
:max,
(,nf.cluster,),:by,
:avg
|