Skip to content

[fix] Don't evaluate threshold for historical data #666 #669

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

Merged
merged 6 commits into from
May 29, 2025

Conversation

pandafy
Copy link
Member

@pandafy pandafy commented May 21, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Fixes #666

"""
if not time or not isinstance(time, datetime):
raise ValueError('Invalid time value')
recent_time = timezone.now() - timedelta(minutes=60)
Copy link
Member Author

Choose a reason for hiding this comment

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

I have chosen 1 hour arbitrarily. We can change this if needed.

Copy link
Member

Choose a reason for hiding this comment

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

I argue that anything older than 5 minutes shouldn't trigger the check of the threshold, because it could come after more recent data has already been ingested and could conflict with recent data, hence generating inconsistent results.

Data older than 1 hour is considered historical data.
"""
if not time or not isinstance(time, datetime):
raise ValueError('Invalid time value')
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't happen right? If we flag the method as private I think we can save these 2 lines of code as this method is going to be used only internally.

"""
if not time or not isinstance(time, datetime):
raise ValueError('Invalid time value')
recent_time = timezone.now() - timedelta(minutes=60)
Copy link
Member

Choose a reason for hiding this comment

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

I argue that anything older than 5 minutes shouldn't trigger the check of the threshold, because it could come after more recent data has already been ingested and could conflict with recent data, hence generating inconsistent results.

@github-project-automation github-project-automation bot moved this from To do (general) to In progress in OpenWISP Contributor's Board May 23, 2025
@pandafy pandafy force-pushed the issues/666-historical-alert branch from bb89f26 to cc3de48 Compare May 27, 2025 09:58
@nemesifier nemesifier added the bug Something isn't working label May 28, 2025
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Changes discussed:

  1. We could move the logic which check whether we're dealing with fresh or old data before the metric is being written, so that if it's historical data we could pass check=False, which is already supported
  2. Some tests are writing old data and expecting notifications to be created, we'll have to update these tests, in some cases we could use freeze_time to write past data if needed.
  3. Let's update this doc page to mention this behavior:
    /monitoring/user/device-checks-and-alert-settings.rst, we can add a new section here and also reference the
    send mode subsection in /openwrt-monitoring-agent/user/settings to explain that we support writing old data which couldn't be collected due to network outages, but when we write this data we don't check threshold nor change the health status (only fresh data will do this).

@nemesifier nemesifier merged commit 2494ee2 into master May 29, 2025
31 checks passed
@nemesifier nemesifier deleted the issues/666-historical-alert branch May 29, 2025 22:23
@github-project-automation github-project-automation bot moved this from In progress to Done in OpenWISP Contributor's Board May 29, 2025
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
Development

Successfully merging this pull request may close these issues.

[bug] Do not send alert for historical metric data
2 participants