Skip to content

chore(aci milestone 3): migrate remaining anomaly detection alerts #93574

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mifu67
Copy link
Contributor

@mifu67 mifu67 commented Jun 13, 2025

Migrate the alerts that didn't get correctly migrated the first run (due to errors with discord actions or the migration stalling).

@mifu67 mifu67 requested a review from ceorourke June 13, 2025 23:18
@mifu67 mifu67 requested review from a team as code owners June 13, 2025 23:18
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 13, 2025
Comment on lines +731 to +737
alert_rules = AlertRule.objects_with_snapshots.filter(
status__in=[
AlertRuleStatus.PENDING.value,
AlertRuleStatus.NOT_ENOUGH_DATA.value,
],
detection_type="dynamic",
).filter(~Exists(AlertRuleDetector.objects.filter(alert_rule_id=OuterRef("id"))))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main change is here—fetching the anomaly detection alerts that were not migrated.

AlertRuleTriggerActionType.SLACK.value: "Slack",
AlertRuleTriggerActionType.MSTEAMS.value: "Microsoft Teams",
AlertRuleTriggerActionType.OPSGENIE.value: "Opsgenie",
AlertRuleTriggerActionType.DISCORD.value: "Discord",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this.

Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/workflow_engine/migrations/0070_migrate_remaining_anomaly_detection_alerts.py

for 0070_migrate_remaining_anomaly_detection_alerts in workflow_engine

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

Comment on lines +441 to +442
else:
return "Email [removed]"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this.

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 87.75510% with 54 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...0070_migrate_remaining_anomaly_detection_alerts.py 83.38% 54 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #93574       +/-   ##
===========================================
+ Coverage   46.30%   88.00%   +41.69%     
===========================================
  Files       10306    10324       +18     
  Lines      594236   595501     +1265     
  Branches    23141    23141               
===========================================
+ Hits       275175   524079   +248904     
+ Misses     318568    70929   -247639     
  Partials      493      493               

condition_result=DetectorPriorityLevel.OK,
).exists()

def test_simple_trigger_action(self):
Copy link
Member

Choose a reason for hiding this comment

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

Is there a test case that replicates the situation the remaining alerts are in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants