Smoothing

Autosmooth

FunctionDescriptionExample
autosmooth()Automatically removes noise while preserving the trend of the metric.autosmooth(<METRIC_NAME>{*})

The autosmooth() function applies a moving average with an automatically selected span. It smooths a timeseries while preserving its trend. In this example, the function chooses the optimal span to smooth the timeseries:

autosmooth illustration

When used on a group by query, such as avg by, the same span is applied on all the timeseries. If used on several metrics in the same graph, different spans can be selected to optimally smooth each one of the metric timeseries.

The algorithm is inspired by the ASAP algorithm-you can read more about it in this blog post.

The autosmooth() function cannot be used in monitors. Being that the span is chosen dynamically, the result of applying the function could change from minute to minute, making threshold setting difficult and leading to alert flapping.

Exponentially weighted moving average

Ewma 3

FunctionDescriptionExample
ewma_3()Compute the exponentially weighted moving average over a span of 3.ewma_3(<METRIC_NAME>{*})

Note: The span value is twice the weighted average age of the series. So ewma_3() is comparable to a 3-day rolling average.

Example:

If a metric 10 + x%10 {*} increments itself by 1 starting from 10 until it drops back to 10 after 10 data points, then ewma3(10 + x%10 {*}) has the following shape:

EWMA3

Ewma 5

FunctionDescriptionExample
ewma_5()Compute the exponentially weighted moving average over a span of 5.ewma_5(<METRIC_NAME>{*})

Note: The span value is twice the weighted average age of the series. So ewma_5() is comparable to a 5-day rolling average.

Example:

If a metric 10 + x%10 {*} increments itself by 1 starting from 10 until it drops back to 10 after 10 data points, then ewma5(10 + x%10 {*}) has the following shape:

EWMA5

Ewma 7

FunctionDescriptionExample
ewma_7()Compute the exponentially weighted moving average over a span of 7.ewma_7(<METRIC_NAME>{*})

Note: The span value is twice the weighted average age of the series. So ewma_7() is comparable to a 7-day rolling average.

Ewma 10

FunctionDescriptionExample
ewma_10()Compute the exponentially weighted moving average over a span of 10.ewma_10(<METRIC_NAME>{*})

Note: The span value is twice the weighted average age of the series. So ewma_10() is comparable to a 10-day rolling average.

Example:

If a metric 10 + x%10 {*} increments itself by 1 starting from 10 until it drops back to 10 after 10 data points, then ewma10(10 + x%10 {*}) has the following shape:

EWMA10

Ewma 20

FunctionDescriptionExample
ewma_20()Compute the exponentially weighted moving average over a span of 20.ewma_20(<METRIC_NAME>{*})

Note: The span value is twice the weighted average age of the series. So ewma_20() is comparable to a 20-day rolling average.

Example:

If a metric 10 + x%10 {*} increments itself by 1 starting from 10 until it drops back to 10 after 10 data points, then ewma20(10 + x%10 {*}) has the following shape:

EWMA20

Median

Median 3

FunctionDescriptionExample
median_3()Rolling median with a span of 3.median_3(<METRIC_NAME>{*})

Note: The span value is the number of data points. So median_3() uses the last 3 data points to calculate the median.

Median 5

FunctionDescriptionExample
median_5()Rolling median with a span of 5.median_5(<METRIC_NAME>{*})

Note: The span value is the number of data points. So median_5() uses the last 5 data points to calculate the median.

Median 7

FunctionDescriptionExample
median_7()Rolling median with a span of 7.median_7(<METRIC_NAME>{*})

Note: The span value is the number of data points. So median_7() uses the last 7 data points to calculate the median.

Median 9

FunctionDescriptionExample
median_9()Rolling median with a span of 9.median_9(<METRIC_NAME>{*})

Note: The span value is the number of data points. So median_9() uses the last 9 data points to calculate the median.

Weighted

Weighted() is only available when querying `SUM BY` on gauge type metrics.
FunctionDescriptionExample
weighted()Automatically removes noise while preserving the proper weight of transient tags.sum:(<GAUGE_METRIC_NAME>{*}).weighted()

The weighted() function accounts for the short-lived lifespan of transient, churning tag values when summing gauge metrics in space to prevent artificial spikes.

This function is automatically appended to queries on gauge metrics if both of the following conditions are met:

  1. The metric has a regular, consistent submission interval that is also specified on Metrics Summary
  2. The metric is aggregated with SUM by (for example, sum: mygaugemetric{*})

Here is an example graph of the original query with inaccurate spikes (in purple) and the query with the properly weighted calculation (in green):

Example graph comparing queries with and without the weighted modifier

For more information on the weighted() modifier, see How does weighted() work?.

Other functions


PREVIEWING: mervebolat/span-id-preprocessing