Rolling quantile
To calculate the rolling quantile advanced function, we use the quantile_over_time
function of the Prometheus engine.
To determine the upper and lower bounds, we adjust them using standard deviations. Instead of computing the standard deviation over the entire time range, we compute it over a specific window of past data.
When computing, we calculate the deviations over the original series (past data) and apply them to future events. This is because the standard deviations of the predicted bands would be extremely close to zero. We chose this approach because quantiles are generally stable metrics.
lower = avg_over_time(
(quantile_over_time(0.16, $Query[5m:])
-$Bound*stddev_over_time($Query[5m:]))[5m:])
upper = avg_over_time(
(quantile_over_time(0.84, $Query[5m:])
+$Bound*stddev_over_time($Query[5m:]))[5m:])
For an in-depth discussion of the rolling quantile functions, see these external resources:
-
Quantile regression in StatsModels
-
histogram_quantile() in Prometheus querying functions