add alert query mode metadata - #1707
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds ChangesAlert query type and contracts
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AlertRequest
participant AlertConfig
participant AlertAuthorization
participant DatasetAccess
Client->>AlertRequest: submit queryType and datasets
AlertRequest->>AlertConfig: resolve or validate datasets
Client->>AlertAuthorization: access alert
AlertAuthorization->>AlertConfig: inspect query_type
AlertAuthorization->>DatasetAccess: authorize PromQL dataset
DatasetAccess-->>AlertAuthorization: allow or deny
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/alerts/alert_types.rs`:
- Around line 94-97: The PromQL guard in validate() is too late because
Alerts::load still enqueues unsupported ThresholdAlert entries before
validation. Update the load/scheduling path so unsupported
AlertQueryType::Promql alerts are filtered out or marked disabled before
creating an AlertTask::Create, using the existing validate() /
AlertError::NotPresentInOSS logic as the source of truth. Make sure both
occurrences in alert_types.rs are covered so OSS never schedules PromQL alerts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bd53268e-dd27-4454-a46a-b83b6e7fb28d
📒 Files selected for processing (8)
src/alerts/alert_enums.rssrc/alerts/alert_structs.rssrc/alerts/alert_traits.rssrc/alerts/alert_types.rssrc/alerts/mod.rssrc/handlers/http/alerts.rssrc/lib.rssrc/metastore/metastore_traits.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/alerts/mod.rs`:
- Around line 153-162: The OSS alert loading path is aborting on unsupported
alert types because `load()` propagates errors from `alert_from_config_oss`, so
a single anomaly or forecast config stops later alerts from being loaded. Update
the alert-loading logic in `load()` to mirror the unschedulable-alert handling
below by skipping `AlertError::NotPresentInOSS` cases instead of returning
early, while keeping supported `Threshold` alerts loaded normally through
`alert_from_config_oss`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
persist queryType for alerts: builder, code, or promql defaults old alerts to builder accepts legacy queryType=sql as code reserves old creationType keys treats builder/code as SQL modes for auth and dataset resolution.
8907ea7 to
4ecf429
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/alerts/alert_structs.rs`:
- Around line 338-355: The ThresholdAlert::validate path must avoid SQL parsing
and query authorization for Promql alerts. Branch on get_query_type(): retain
resolve_stream_names and user_auth_for_query for Builder and Code, while
validating and authorizing the explicitly configured dataset for Promql; add a
regression test that validates creation of a PromQL alert.
In `@src/alerts/mod.rs`:
- Around line 180-195: Update the Promql branch in the alert authorization flow
around AlertQueryType::Promql so authorization is enforced against every dataset
the PromQL query can access, not only alert.datasets[0]. Ensure PromQL
evaluation, including execute_local_query, is constrained to that authorized
dataset regardless of metric names in alert.query, and reject queries that would
access any other dataset.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 68022536-bb0f-4041-ad4f-3f3e80ee1a61
📒 Files selected for processing (6)
src/alerts/alert_enums.rssrc/alerts/alert_structs.rssrc/alerts/alert_traits.rssrc/alerts/alert_types.rssrc/alerts/mod.rssrc/handlers/http/alerts.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- src/alerts/alert_types.rs
- src/handlers/http/alerts.rs
persist queryType for alerts: builder, code, or promql
defaults old alerts to builder
accepts legacy queryType=sql as code
reserves old creationType keys
treats builder/code as SQL modes for auth and dataset resolution
Summary by CodeRabbit
New Features
Bug Fixes
sqlquery type value.