pub async fn create_alert(
pool: &Pool<MySql>,
alert_type: &str,
severity: &str,
service: &str,
message: &str,
metadata: Option<Value>,
org_id: Option<i64>,
app_id: Option<i64>,
instance_id: Option<i64>,
region_id: Option<i64>,
node_id: Option<i64>,
) -> Result<Alert>
Expand description
Creates a new alert in the database.
This function inserts a new alert record with the provided parameters and adds an initial history record to document the alert creation.
§Arguments
pool
- Database connection pool for executing the queryalert_type
- Type of alert (e.g., “cpu_usage”, “memory_usage”, “disk_space”)severity
- Severity level of the alert (critical, warning, info)service
- Name of the service that generated the alertmessage
- Alert message text describing the issuemetadata
- Optional JSON data with additional alert detailsorg_id
- Optional organization ID related to the alertapp_id
- Optional application ID related to the alertinstance_id
- Optional instance ID related to the alertregion_id
- Optional region ID related to the alertnode_id
- Optional node/worker ID related to the alert
§Returns
Ok(Alert)
- Successfully created alert, including database-assigned fieldsErr(anyhow::Error)
- Failed to create alert