Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: window size for small time ranges #6964

Merged
merged 3 commits into from
Jan 29, 2025
Merged

fix: window size for small time ranges #6964

merged 3 commits into from
Jan 29, 2025

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Jan 29, 2025

Summary

There are two issues this change fixes

  1. 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.
  2. The end of the season period should not include the eval window. These are 5 data points used to derive the predicted value

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.

  • Behavior:
    • Fix getMovingAvg in seasonal.go to handle cases where window size exceeds series length by dynamically adjusting the window size.
    • Correct seasonal period calculation in prepareAnomalyQueryParams in params.go to exclude the evaluation window.
  • Logging:
    • Change log level from Info to Debug for predicted series details in getPredictedSeries in seasonal.go.
  • Misc:
    • Simplify boolean check in GetAlertsInfo in db.go by using !rule.PostableRule.Disabled.

This description was created by Ellipsis for 89b34ce. It will automatically update as commits are pushed.

Copy link

welcome bot commented Jan 29, 2025

Welcome to the SigNoz community! Thank you for your first pull request and making this project better. 🤗

@github-actions github-actions bot added the bug Something isn't working label Jan 29, 2025
@srikanthccv srikanthccv marked this pull request as ready for review January 29, 2025 08:11
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 89b34ce in 20 seconds

More details
  • Looked at 103 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/query-service/rules/db.go:618
  • Draft comment:
    The change from if rule.PostableRule.Disabled == false to if !rule.PostableRule.Disabled improves readability and is a good practice.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The change in the conditional statement is a good practice for readability and maintainability.
2. pkg/query-service/rules/db.go:616
  • Draft comment:
    Do not add non-ClickHouse related functions to the ClickHouseReader interface. Use the DAO in the telemetry instance to access such information instead. This is also applicable in other parts of the file where similar patterns are observed.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_vEFruML23CKVIgL5


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@srikanthccv srikanthccv enabled auto-merge (squash) January 29, 2025 09:15
@srikanthccv srikanthccv merged commit 333f90d into main Jan 29, 2025
16 checks passed
@srikanthccv srikanthccv deleted the fix-anomaly branch January 29, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Anomaly alert incorrectly triggers for small windows
2 participants