The forecasting service turns a metric’s history into its expected range in six steps (see the overview for when this happens and what the service receives). Each step is explained first in plain terms; the Technical details give the exact rules. How well the result works, and its limits, are in Test Results and Known Limits .
The Steps
The technical details use a few terms throughout:
- Robust spread (σ). How much values usually move, measured so that a few extreme values do not inflate it: the median absolute deviation from the median, multiplied by 1.4826 so that it matches the standard deviation of normally distributed data. For the values 10, 11, 9, 10 and 100, the standard deviation is about 40, while σ is about 1.5.
- One-step miss (residual). For each past record, the actual value minus the value the forecast would have given one step before.
- Normal quantile Φ⁻¹(q). The value that a share q of a standard normal (“bell curve”) distribution stays below: Φ⁻¹(0.99865) ≈ 3.
Step 1: Line Up the Records in Time
Records rarely arrive at perfectly regular times, so they are first placed on a regular time grid: one point per hour, day, week or month.
- The grid follows your data. On Automatic, the grid is the usual gap between records: a metric profiled every night gets a daily grid, one profiled every Monday a weekly grid. Several records in the same period are averaged into one.
- A frequency you set is used, unless your records are much sparser than it (a metric profiled every Monday, left on Daily). Then the records’ own step is used, otherwise six days out of seven would be invented rather than measured.
- Missing runs are bridged, not counted. A missing run is filled with the last known value so that the calculations can run, but it never counts as a record: not towards Minimum Training Data, and not when measuring how far forecasts miss.
- The range is placed when your records arrive. If profiling runs at 06:00, the range is computed for 06:00; on monthly metrics, on the day your records arrive (the 25th, or the last day of the month). A record that falls between two points of the range is checked against a straight-line blend of the two.
- A frequency the service does not support puts the model in the Error state (see Custom Frequencies ).
- A new metric waits for enough history. No range is computed before the metric has Minimum Training Data records (30 by default; on weekly and monthly grids the number is read as days, with at least 6 records). Until then the metric is in the TRAINING state and no record is checked.
Technical details
The typical gap g is the median time between consecutive records, ignoring re-runs less than a minute apart; it needs at least 3 gaps.
declared step s kept, unless g ≥ 2·s or the history would span more than 50,000 steps
automatic step the coarsest of {1 hour, 1 day, 7 days, 1 month} with g ≥ 0.75 · step
value of a step mean of the records inside it
empty step last known value, marked "not observed"
Steps marked “not observed” are excluded from the minimum history and from the one-step misses of Step 5, so filled-in values never make the range look more regular than the metric is.
Anchor. The range points are placed at the records’ typical offset inside their step: the median offset of the latest 60 records (06:00 for a nightly run). Months, quarters and years have different lengths, so for those grids the offset is measured from the start or from the end of the period, whichever the records keep to more closely (the smaller mean absolute deviation of the offsets): a record on the 25th stays on the 25th, a month-end record stays at month end.
Minimum history. With m the Minimum Training Data setting and s the step:
required = max(m, 2) on grids of one day or finer
required = max(min(⌈m · 1 day / s⌉, m), min(6, m), 2) on coarser grids
Step 2: Look for a Weekly or Daily Pattern
Many metrics repeat themselves: fewer rows at weekends, more activity in office hours, nothing at night. Before anything else, the service checks whether the metric has such a pattern, so that a normal quiet Sunday is never mistaken for a problem.
- On daily metrics it checks whether each day of the week behaves in its own way.
- On hourly metrics it checks each hour of the day, and each hour of the week (office hours on weekdays, quiet weekends).
The test is a contest between two simple predictions of each recent record: “like the same day in the previous weeks” and “like the last few records”. If the first is clearly better, the metric has a pattern. A pattern needs three full cycles of history (three weeks) to be recognised. Days and hours are in UTC.
Technical details
Candidate periods P: 7 on a daily grid; 24 and 168 on an hourly grid. Other grids have no candidate. A period is tested only when the history holds at least 3 of them, on the points of the last 8 periods.
local level ℓ_t = median(x_{t−P}, …, x_{t−1})
seasonal prediction ℓ_t + median over k = 1..3 of (x_{t−kP} − ℓ_{t−kP})
plain prediction ℓ_t + median over the last 3 points of (x − ℓ)
typical error E mean over the phases of the median |prediction error| in that phase
accept P if E_seasonal ≤ 0.7 · E_plain
Both predictions are made relative to the local level, so a growing metric or a recent jump favours neither. The error is taken as a median per phase (per weekday, per hour), so an incident that touches one week cannot create a pattern; a real pattern shows at the same phases every week. On an hourly grid, the weekly period 168 must also beat the daily period 24 by the same factor.
Step 3: Clean Up the History
The history holds everything that happened, including incidents nobody has classified yet. If the model learned from them, the range would widen after every incident and hide the next one. So the service separates one-off events from real behaviour:
- Isolated spikes are cut back. A record far from its neighbours is brought back towards them. On a metric with a pattern this is done after taking the pattern out, so a quiet Sunday is not treated as a drop. On a metric that holds the same value around it (a null percentage at 0% most days), one or two records in a row that differ from it are set back to that value: three or more are a level.
- The latest records are checked too. The newest record has no neighbours after it, yet it is exactly where a new anomaly sits, because a new range is computed after every upload. The latest records are compared with the four weeks (28 records) before them instead.
- What keeps happening is kept. A spike is rare by definition. If more than 5% of the history would be cut on the same side, those records are a real state of the metric (a regular dip, a second operating level) and they stay, so the range includes them.
- A lasting change becomes the new normal. When the latest three or more records all sit far from the previous ones, on the same side, the metric has moved (a new data source, a migration). The earlier history is moved to the new level, so you get up to three alerts when the change happens instead of an alert every day from then on.
Your classifications act here: a record classified as Anomaly is no longer part of the history, so it can neither widen the range nor become the new level. A record classified as False Positive stays and is treated like any other record (see Step 5 for its effect).
Figure 1. Five days of an hourly CPU metric from a public benchmark. Left: cutting every unusual value would remove a dip that happens about one hour in nine, and every future dip would become an anomaly. Right: because the dips recur, they are kept; only the rare upward spikes are cut.
Technical details
The cleaning works on the values minus the pattern found in Step 2 (the median of each phase); the pattern is added back afterwards.
Spikes. Each point is compared with a window of 7 points centred on it (3 on each side, fewer at the ends). With m and MAD the median and the median absolute deviation of the window:
limits m ± 3.5 · 1.4826 · MAD
beyond the point is moved to the limit (winsorised)
per side applied only if it moves at most 5% of the points on that side;
otherwise that side is a recurring state and is left untouched
How much was taken off each point is remembered, for the false-positive rule of Step 5.
Latest records. Let c be the median and σ the robust spread of the 28 points before the latest run, and count the latest points that are all above c + 3.5σ (or all below c − 3.5σ):
1 or 2 points clipped to the limit
3 or more level shift to L = median of the run:
older points × L / c if the series is always positive
older points + (L − c) otherwise
Scaling a positive series keeps the spread proportional to the level: a table that doubles gets a range about twice as wide.
Step 4: Forecast the Next Records
Now the service estimates the next values of the metric.
-
Constant metrics (always the same value, such as a column count, or 0% nulls in a mandatory column) need no forecast: the expected value is the constant, and any change is an anomaly. For these metrics any change is news. A one-off change, even if nobody classifies it, does not move the expected value: when the metric comes back to its usual value, that record is normal. If the metric stays at a new value for three records, that value becomes the new constant.
-
All other metrics are forecast with exponential smoothing, a well-established method that gives more weight to recent records than to old ones and works out by itself whether the metric has a trend, and whether that trend is slowing down. When Step 2 found a pattern, the pattern is taken out first, the remaining level and trend are forecast, and the pattern is put back on top. A pattern can be:
- fixed: weekends are about 150 rows lower, whatever the size of the table;
- proportional: weekends are about 40% lower, so the dip grows as the table grows (tried only when the metric is always positive).
The service tries both and keeps the one that gives the narrower range on the metric’s own past.
On-premises installations can also enable a pre-trained time-series model: a model trained in advance on a large public collection of time series, which forecasts a new metric without being trained on it. When enabled, it is tried next to exponential smoothing and is used for a metric only if its range is at least 10% narrower on the metric’s own past. It is off by default.
Technical details
Whatever the method, Step 4 hands three things to Step 5: the central forecast m_h for h steps ahead; the one-step misses e_t; and the spread growth r_h, how much less certain step h is than step 1.
Exponential smoothing. The level ℓ and the trend b are updated after every point; φ ≤ 1 damps the trend:
level ℓ_t = α · x_t + (1 − α) · (ℓ_{t−1} + φ · b_{t−1})
trend b_t = β · (ℓ_t − ℓ_{t−1}) + (1 − β) · φ · b_{t−1}
forecast x̂_{t+h} = ℓ_t + (φ + φ² + … + φ^h) · b_t
The variants (no trend, trend, damped trend; additive or multiplicative errors) are fitted and the one with the best information criterion is kept: a score that rewards a close fit and penalises extra parameters. The one-step misses are the model’s own one-step-ahead predictions over the history. When no variant can be fitted (a very short or degenerate history), the forecast is the last value and the spread grows as √h.
Pattern. The profile s (or f) is the median, per phase, of the values measured against a moving median, over the last 8 periods; it is normalised to average 0 (or 1):
fixed x_t = y_t + s_phase m_h = ŷ_h + s_phase(h)
proportional x_t = y_t · f_phase m_h = ŷ_h · f_phase(h)
choice the variant with the smaller σ(e) · mean(r)
Spread growth. r_h is the half-width of the model’s ±1σ forecast interval at step h divided by the half-width at step 1, never decreasing.
Pre-trained model. It returns quantile forecasts: the median is m_h, and the 15.87% and 84.13% quantiles (±1σ for a normal distribution) give r_h. Its misses are true backtests: each of the last 100 observed points is predicted from the points before it only. It is used for a metric when, on at least 14 points where both methods have a miss and calibrated as in Step 5:
width = (L + U) / 2 · mean(r_h) pre-trained model used if width_model ≤ 0.9 · width_smoothing
Step 5: Decide How Wide the Range Is
This is the step that decides how many alerts you get.
The service replays the metric’s history and asks, for every past record: “how far was the forecast off?” Those misses describe how much the metric naturally moves, and in which direction. The range is then set so that only a small, chosen share of normal records falls outside it. That share is the Sensitivity:
| Sensitivity | Value | Normal records expected outside the range | With daily profiling |
|---|---|---|---|
| High: more anomalies | 0.7 | about 1 in 115 | about 3 false alerts per metric per year |
| Medium (recommended) | 0.9 | about 1 in 370 | about 1 false alert per metric per year |
| Low: fewer anomalies | 1.0 | about 1 in 16,000 | almost never |
A few choices make the range fit each metric:
- The two sides are set separately. The lower bound comes from the misses below the forecast, the upper bound from the misses above. A table that sometimes loads late (drops) but never doubles (jumps) gets a generous lower bound and a tight upper bound, so a jump is still caught.
- Rare misses are measured, not assumed. The width comes from the metric’s real misses, not from a bell-curve assumption, so a metric with occasional big misses gets a wider range than its typical miss alone suggests.
- Each side has a minimum width: 3 typical misses at Medium (2.6 at High, 4 at Low). New metrics, with fewer than 100 past misses, start with exactly this minimum.
The share in the table is what the range aims for on normal behaviour. Real metrics also change behaviour now and then (a new load schedule, a drift); right after such a change the forecasts miss more than usual, so more records are flagged until the history catches up. The test results show how many in practice.
Figure 2. How far the forecasts of the CPU metric of Figure 1 missed. A range with the same width on both sides (dashed) would leave 6% of the records below it, because the recurring dip makes the low side much heavier. Setting each side from its own misses (solid) keeps both sides at the chosen share.
False Positives Widen Their Side
Each record classified as False Positive in the last 90 days widens the side of the range it fell on, a little for each one and up to a cap, and always far enough that the same value is not flagged again (also on a constant metric). Several false positives in the same period of the grid count as one. The effect of every classification is described in Classify Incidents and Anomalies .
Technical details
From sensitivity to a target rate. The sensitivity p (0 to 1) gives a number of standard deviations z, and z gives the target share α of normal records outside the range (both sides together):
z = 1.5 + 1.5 · (p − 0.1) / 0.8 for p ≤ 0.9 (0.7 → 2.625, 0.9 → 3)
z = 3 + 10 · (p − 0.9) for p > 0.9 (1.0 → 4)
α = erfc(z / √2) the two-sided normal tail at z
Each side from its own misses (split-conformal calibration). σ is the robust spread of all the misses e (if their MAD is 0, 1.2533 times their mean absolute deviation). For one side, with N misses on that side and target α/2:
N < 100 side = z · σ
N ≥ 100 k = max(⌊α/2 · N⌋, 5)
w = the (k+1)-th largest miss on this side
w ← w · Φ⁻¹(1 − α/2) / Φ⁻¹(1 − k/N)
side = max(z · σ, w)
At Medium a side should leave out 0.135% of the records, but even 1,000 misses hold only one or two that extreme. So the service reads the most extreme quantile the data does support, beyond which at least 5 misses lie, and extends it to the target with the ratio a normal distribution would have between the two rates. The normal distribution is used only for that ratio and for z: the shape of the tail comes from the real misses.
False positives. For each false positive in the 90 days before the last record, with d its distance from the forecast (its one-step miss plus whatever Step 3 cut from it):
side ← side + 0.5 · σ per false positive on that side (both sides if unknown), at most + 2 · σ
side ← max(side, |d|) the same value now falls inside
The result is two widths for the next step: L below the forecast and U above it. The Model tab shows them as z_lower = L / σ and z_upper = U / σ.
Step 6: Look a Few Periods Ahead
Each forecast covers the next Forecast Length periods, so that records arriving late can still be checked, and always at least about one and a half of the metric’s usual gaps past the last record, so the next run is checked even when it is late. The range gets wider for periods further ahead, because forecasts are less certain the further they look. Finally, the range is kept within what the metric can be:
- a metric that has never been negative never gets a negative lower bound;
- a percentage metric (type ending in
_perc, such as null % or distinct %) whose history lies between 0 and 1 never gets a bound above 1 (a percentage stored from 0 to 100 is not capped); - a metric that never varied in its recent history, but is not exactly constant, gets a minimum width of 1% of its level, so its range is never zero wide;
- when most of the history holds one value (a null percentage at 0% on most days, a count that is usually 0), that value is always inside the range: a value the metric takes most of the time is never an anomaly.
When a record arrives, it is compared with the range at its time. If it is outside, its severity grows with how far outside it is, compared with half the width of the range (see Severity ).
Technical details
With g the typical gap, s the grid step and the widths L and U of Step 5, for each step h of the horizon H:
H = max(Forecast Length, ⌈1.5 · g / s⌉)
lower_h = m_h − max(L · r_h, floor)
upper_h = m_h + max(U · r_h, floor)
floor = 1e-9 · max(1, |level|) constant metrics (any change is flagged)
= 1% of the median of the last 30 values non-constant metric with σ = 0
= 0 otherwise
lower_h ≥ 0 when the history has no negative value
lower_h, upper_h, m_h ≤ 1 for *_perc metrics whose history lies in [0, 1]
lower_h ≤ M ≤ upper_h M = median of the cleaned history, when its MAD is 0
The floor tied to the level applies only where the range would otherwise have no width: applied everywhere, it would hide real changes on large, smooth metrics.