Skip to content

Conversation

jasonyuezhang
Copy link
Owner

We're seeing some errors with the detect anomalies request when a dynamic alert has been edited. Send these so that the data is keyed according to the IDs that are passed.


Copied from getsentry#101045
Original PR: getsentry#101045

Copy link

Ensure Source ID and Source Type Are Included in Store Data Request for Anomaly Detection

This pull request modifies the send_historical_data_to_seer logic in src/sentry/seer/anomaly_detection/store_data.py to include the source_id and source_type fields when passing alert configuration to the store data request for anomaly detection. The update addresses errors seen when dynamic alerts are edited, by ensuring data is keyed using these explicit identifiers. The PR introduces a lookup for the associated QuerySubscription and, if not found, raises a ValidationError. The function now constructs an AlertInSeer object that contains the alert rule id, the derived subscription id, and specifies the source type as SNUBA_QUERY_SUBSCRIPTION.

Key Changes

• Added import of DataSourceType and inclusion of QuerySubscription model.
• Replaced the previous method of constructing AlertInSeer with one that includes id, source_id, and source_type.
• Inserted a lookup for QuerySubscription based on snuba_query.id and associated error handling.
• Updated the StoreDataRequest construction to use the newly-constructed AlertInSeer object.

Affected Areas

src/sentry/seer/anomaly_detection/store_data.py
• Anomaly detection store data request logic
• Alert configuration payload structure

This summary was automatically generated by @propel-code-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants