fix: window size for small time ranges #6964
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
There are two issues this change fixes
getMovingAvg
returns an incorrect window average if the window size is larger than the length of the series. When does this happen? It happens when the eval window used in the alert is smaller, such as 5 minutes. This is not an issue for any eval window greater than 7 minutes.Let's assume daily seasonality
current period - time range choose from ui, or eval window time from an alert; let's say they are
[start, end]
the current season should be in a time range till the start and shouldn't overlap with the current period.
the current logic is [start-1d, end], but it should be [start-1d, start]
Fixes #6963
Important
Fix moving average calculation and seasonal period logic in anomaly detection, and simplify boolean check in alerts info retrieval.
getMovingAvg
inseasonal.go
to handle cases where window size exceeds series length by dynamically adjusting the window size.prepareAnomalyQueryParams
inparams.go
to exclude the evaluation window.Info
toDebug
for predicted series details ingetPredictedSeries
inseasonal.go
.GetAlertsInfo
indb.go
by using!rule.PostableRule.Disabled
.This description was created by
for 89b34ce. It will automatically update as commits are pushed.