mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-06 08:09:24 +00:00
#5253 The overall goal of this PR is to migrate alerts data out of `meta` table into `alerts` table. To accomplish this three main changes are made. Unfortunately, all three of these changes need to be synchronized and submitted in the same PR. 1. A new migration script is added to - Parse alerts JSON currently stored in the `meta` table into Rust models for alerts. These Rust models are isolated to the migration script since they represent the schema of alerts as they are stored in the `meta` table before this migration executes. - Convert those Rust models into Sea ORM entities for alerts. - Insert all the Sea ORM entities for alerts into the new `alerts` table. 2. Create get/put/delete/list methods for accessing the data in the `alerts` table - These functions use SeaORM to query and update the database. - These functions must also convert between SeaORM alert entities and the application's current data model for alerts (as defined in `config::meta::alerts`. - It's entirely expected that the models inside `config::meta::alerts` will change over time. When this happens in the future, developers will need to update the transformation functions between SeaORM alert entities and the models in `config::meta::alerts`. Luckily, the compiler should help to direct developers to where these transformation functions need to be updated. 3. Update the old logic in `/src/service/db/alerts.rs` that previously read and wrote alerts to the `meta` table so that it now reads and writes alerts to the `alerts` table. - The methods for accessing the `meta` table included logic for triggering "cache update events" to the cluster coordinator and for sending events to the super cluster queue. Since the new logic accesses the `alerts` table rather than the `meta` table, this logic for emitting events had to be reproduced. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new `ListAlertsParams` struct for flexible querying of alerts. - Enhanced `TriggerCondition` struct with new timing parameters. - Added new error variants for improved error handling in alert management. - Created a comprehensive alert management system with CRUD operations. - Added integration tests for various functionalities related to alerts and dashboards. - Introduced a new `Alerts` variant in the `FolderType` enum for better folder management. - **Bug Fixes** - Improved error handling for folder deletion when alerts are present. - **Documentation** - Updated documentation for several functions to clarify their scope and functionality. - **Chores** - Added new dependencies to support additional functionality. - Introduced migration scripts for database schema changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->