Skip to content

update: add tags, created to alerts #1389

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 3 commits into from
Jul 27, 2025

Conversation

nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Jul 25, 2025

  • similar to dashboards, server supports adding tags while creating alerts
  • list alerts by tags by providing query param tags=
  • list_tags endpoint provides list of unique tags from all alerts
  • add created in alert creation

Summary by CodeRabbit

  • New Features

    • Added support for optional tags on alerts, allowing users to categorize and organize alerts with custom tags.
    • Introduced the ability to filter alerts by tags through the alerts listing endpoint.
    • Added a new API endpoint to retrieve a list of all available alert tags.
  • Bug Fixes

    • Improved error handling for invalid query parameters when filtering alerts by tags.
  • Other Improvements

    • Alert summaries now include tags, datasets, and creation timestamps for better visibility.

similar to dashboards, server supports adding tags while creating alerts
list alerts by tags by providing query param tags=<list of tags>
list_tags endpoint provides list of unique tags from all alerts
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Walkthrough

The changes introduce alert tagging functionality throughout the alert management system. Alerts can now have optional tags, which are stored, filtered, and listed via new and updated methods. The HTTP API is extended to support tag-based alert filtering and to provide an endpoint for listing all tags. Supporting changes include error handling for invalid query parameters and updates to alert summaries.

Changes

File(s) Change Summary
src/alerts/mod.rs Added optional tags and created fields to alert structs; implemented tag filtering, listing, and summary methods; extended error types; updated alert listing signature.
src/handlers/http/alerts.rs Modified alert list handler to support tag filtering via query parameters; added handler to list all tags.
src/handlers/http/modal/server.rs Added new GET route /alerts/list_tags for listing all tags in the alerts web scope.
src/prism/home/mod.rs Updated call to list_alerts_for_user to include an explicit empty tag vector argument.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HTTP_Handler as HTTP Handler
    participant Alerts
    participant DB as Database

    Client->>HTTP_Handler: GET /alerts?tags=foo,bar
    HTTP_Handler->>Alerts: list_alerts_for_user(session, tags=["foo", "bar"])
    Alerts->>DB: Query alerts for user with tags filter
    DB-->>Alerts: Matching alerts
    Alerts-->>HTTP_Handler: Filtered alerts
    HTTP_Handler-->>Client: JSON summaries of alerts

    Client->>HTTP_Handler: GET /alerts/list_tags
    HTTP_Handler->>Alerts: list_tags()
    Alerts->>DB: Query all alerts
    DB-->>Alerts: All alerts
    Alerts-->>HTTP_Handler: Unique, sorted tag list
    HTTP_Handler-->>Client: JSON tag list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

for next release

Suggested reviewers

  • parmesant

Poem

In the garden of alerts, new tags now bloom,
Filter and find them, no more gloom!
List all the labels, sorted and neat,
Dashboards and rabbits—what a treat!
With every new tag, the system grows bright,
🐇 Hopping through code, everything’s right!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe01d39 and 5218bc8.

📒 Files selected for processing (1)
  • src/alerts/mod.rs (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/alerts/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: coverage
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/handlers/http/modal/server.rs (1)

272-278: Consider using a more appropriate authorization action.

The new route implementation follows existing patterns correctly. However, using Action::ListDashboard for authorization seems semantically incorrect for listing alert tags. Consider using Action::GetAlert or a similar alert-related action for better semantic alignment.

                 web::resource("/list_tags").route(
                     web::get()
                         .to(alerts::list_tags)
-                        .authorize(Action::ListDashboard),
+                        .authorize(Action::GetAlert),
                 ),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7017c28 and 7df81df.

📒 Files selected for processing (4)
  • src/alerts/mod.rs (12 hunks)
  • src/handlers/http/alerts.rs (3 hunks)
  • src/handlers/http/modal/server.rs (1 hunks)
  • src/prism/home/mod.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: coverage
🔇 Additional comments (19)
src/alerts/mod.rs (14)

22-22: LGTM!

The additional chrono imports are necessary for the new created timestamp functionality.


200-207: LGTM!

The Display trait implementation for AlertType is correct and follows standard Rust patterns.


539-539: LGTM!

The optional tags field is appropriately typed as Option<Vec<String>> and follows the existing pattern for optional fields.


560-560: LGTM!

The tags field is correctly transferred from the request to the config during conversion.


583-583: LGTM!

The tags field is consistently added to AlertConfig with the same optional type.


559-559: LGTM!

Setting the created timestamp to the current UTC time during alert creation is appropriate.


582-582: LGTM!

The created field with DateTime type is appropriate for tracking alert creation time.


613-614: LGTM!

Setting created timestamp and tags to appropriate defaults during migration is correct.


1202-1239: LGTM!

The to_summary method implementation is well-structured and handles optional fields correctly. The JSON map creation follows appropriate patterns for alert summaries.


1278-1279: LGTM!

The InvalidQueryParameter error variant is appropriately added for handling query parameter validation errors.


1302-1302: LGTM!

The HTTP status code mapping to BAD_REQUEST is correct for invalid query parameter errors.


1410-1410: LGTM!

The tags parameter addition to list_alerts_for_user method signature is appropriate for tag-based filtering.


1419-1429: LGTM!

The tag filtering logic is correctly implemented. It properly handles the empty tags case and filters alerts based on tag intersection.


1529-1541: LGTM!

The list_tags method implementation is well-designed. It correctly handles optional tags, flattens the structure, and ensures uniqueness through sorting and deduplication.

src/prism/home/mod.rs (1)

359-359: LGTM!

The addition of an empty tags vector correctly aligns with the updated list_alerts_for_user method signature. Since no tag filtering is needed in this context, passing an empty vector is appropriate.

src/handlers/http/alerts.rs (4)

19-19: LGTM!

The HashMap import is necessary for the new query parameter parsing functionality.


41-55: LGTM!

The query parameter parsing logic is well-implemented. It properly handles tag splitting, trimming, validation, and error cases. The validation to prevent empty tags after filtering is a good defensive programming practice.


57-62: LGTM!

The updated list function correctly passes the parsed tags and uses the new to_summary method for consistent alert summary serialization.


177-180: LGTM!

The list_tags handler function is simple, effective, and follows the established patterns in the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 25, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 25, 2025
@nitisht nitisht merged commit fc29387 into parseablehq:main Jul 27, 2025
14 of 17 checks passed
@nikhilsinhaparseable nikhilsinhaparseable deleted the add-metadata-alerts branch July 27, 2025 12:48
This was referenced Jul 28, 2025
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