Aggregation Functions

Statistical functions are applied to values in each period to calculate period statistics.

Client and Server Calculations

The Charts library provides a built-in capability to calculate some of the aggregate statistics in the user's browser (on the client).

In client-side mode, the browser downloads detailed samples once from the server and calculates statistics in JavaScript. The detailed samples remain in browser memory. When the user clicks one of the chart controls to modify the aggregation period or to view results a different statistic, the browser is able to recompute statistics locally, without requesting the data from the server.

In server-side mode, the client makes requests for aggregate statistics from the server each time the period or function is changed. The server has more compute and memory resources and is able to calculate statistics much faster then the client. The memory required from the browser is minimized since there is no need to download detailed data. However, if the network is slow, the benefits of server-side processing can be outweighed if the client downloads detailed data once and re-uses it for many subsequent re-calculations.

By default, the calculation is performed on the client, unless the requested statistical function is supported only on the server, such as wavg or standard_deviation.

To modify the default behavior, use the server-aggregate setting.

server-aggregate = true

Server and Client Aggregators

Supported both in client- and server-mode. Calculated on client side by default or if server-aggregate is set to false.

Syntax Description
count Number of samples during the period.
min Minimum value during the period.
max Maximum value during the period.
sum Sum of values during the period.
avg Average value during the period.
percentile(n) n-th percentile, for example PERCENTILE(75) or PERCENTILE(99.5).
n is a decimal number between [0, 100].
median Median value, same as 50% percentile.
first First value received during the period.
last Last value received during the period.
delta Delta is the difference between the last value in the period and the last value in the previous period.
If no last value is present in the previous period (empty period), then delta is the difference between the last and first values during the current period.
See also counter aggregator.
counter Sum of the differences between consecutive values in the period.
If the difference between any two values is negative, the difference is replaced with the value itself.
If the difference between values is always non-negative, the counter aggregator returns the same value as the delta aggregator.
Refer to this Example to better understand the difference between COUNTER and DELTA.

Server Aggregators

Not supported in client-mode. Calculated on the server side, regardless of the server-aggregate setting.

Syntax Description
standard_deviation Standard deviation of values during the period.
√ of the variance.
median_abs_dev Median absolute deviation of values during the period.
median(abs(value - median(value))).
wtavg An average created via the multiplication of each component by a factor reflecting importance.
Weight is assigned based on timestamps rather than index.
Data points with older timestamps contribute less to the weighted mean than more recent data.
The weight of a sample is proportional to the current_time – first_time + 1 (in seconds), where current_time is the timestamp of the sample, and first_time is the timestamp of the first sample received during the period.
Weights are normalized, their sum is equal to 1.
Refer to the calculation example below.
wavg A weighted average of samples received during the period.
The weight of a sample is proportional to the index of the sample in the time-ordered array of all samples during the period.
Weights are normalized, their sum is equal to 1.
A weighted average is sum of sample values multiplied by weight.
Refer to the Calculation Example below.
min_value_time Time when the minimum value (min) occurred for the first time during the period.
max_value_time Time when the maximum value (max) occurred for the first time during the period.
threshold_count Number of threshold violations during the period.
A violation is a sequence of one or more successive data points exceeding the specified threshold.
Example: The following values are collected every 5 minutes.
1, 2, 5, 7, 1, 1.
If the threshold is set to 4, then one sequence (5,7) exceeds the threshold.
threshold_duration Total duration of threshold violations during the period in milliseconds.
A violation is a sequence of one or more successive data points exceeding the specified threshold.
Example: The following values are collected every 5 minutes.
1, 2, 5, 7, 1, 1.
If the threshold is set to 4, then one sequence (5,7) exceeds the threshold and its total duration based on linear interpolation is 550 seconds.
If the threshold is 5, then duration is 850 seconds.
For periods at the beginning of the timespan, at the end of the timespan or after a missing period, the value at the beginning of the period is set to the first value, and the value at the end of the period is set to last value.
threshold-percent Percent of time during which the value remained below threshold (no violation).
Formula: threshold_percent = 100 - threshold_duration / period_duration * 100

Interpolation Functions

If the period does not contain any detailed values, they are excluded from the results. The default behavior NONE can be modified by specifying an interpolation function to fill missing periods.

Function Description
NONE No interpolation. Periods without any raw values are excluded from results.
LINEAR Calculate period value using linear interpolation between previous and next period values.
PREVIOUS Set value for the period based on the previous period’s value.
NEXT Set value for the period based on the next period’s value.
VALUE Set value for the period to a specific number.

Examples

AVG, WAVG, and WTAVG Example

See the Excel spreadsheet for testing and calculation.

wtavg(): Weighted time average.

Calculation: Weight = (sample.time - first.time)/(last.time - first.time + 1)

Examples

Box Chart with percentile

Histogram with percentile

Time Chart with delta

Time Chart with count and delta