ed9212ccfb
Introduces AlertV2Definition - a new model that lets users define TSQL queries and threshold conditions that trigger alerts on a configurable evaluation interval. Results are recorded in ClickHouse for history and auditing. Key components: - AlertV2Definition Postgres model: query string, conditions JSON, evaluationIntervalSeconds, alertChannelIds, state (OK/FIRING) - alert_evaluations_v1 ClickHouse table: every evaluation result with state, value, duration, and error (90-day TTL) - scheduleAlertEvaluations cron job (every minute): finds definitions due for evaluation and enqueues individual jobs - evaluateAlertDefinition worker job: runs TSQL query with full tenant isolation, evaluates all conditions, writes to ClickHouse, fires ALERT_V2_FIRING / ALERT_V2_RESOLVED notifications on state change - Delivery via existing Slack, Email, and Webhook channels; new alert types handled in deliverAlert.server.ts without breaking v1 behaviour - Global concurrency limit enforced by the alerts Redis-worker pool https://claude.ai/code/session_01XAz7T33otDLy9G8wz1cS6c