mirror of
https://github.com/monoscope-tech/monoscope.git
synced 2026-11-16 10:18:01 +00:00
* Add widget-integrated alerts feature Enable creating and managing alerts directly from dashboard widget details: - Add widget_id, dashboard_id, and recovery threshold columns to query_monitors - Add Alerts tab to widget expand view with full configuration form - Render threshold marklines on charts (configurable: always/on_breach/never) - Show alert status indicator on widget headers (bell icon with colors) - Add source column to Alerts page showing Widget vs Log Explorer origin - Sync widget query changes to linked alerts automatically - Delete alerts when widgets are removed from dashboards - Support recovery thresholds (hysteresis) to prevent alert flapping - Populate widget alert status at render time for real-time indicators * Auto-format code with fourmolu * Fix widget alerts: clone on duplicate, sync queries, persist status - Clone alerts when duplicating widgets with new alert ID tied to new widget - Sync widget query changes to associated alert's logQuery and logQueryAsSql - Prevent direct query modification for widget-tied alerts - Add current_status column to track alert state (migration 0026) - Extract normalizeWidgetId, alertActiveWindow, mkMarkLine helpers - Use stored current_status in getWidgetAlertStatuses instead of computing * Auto-format code with fourmolu * Fix widget alerts: add missing current_status field and lowercase status values - Add current_status to SQL queries in getAlertsByTeamHandle, getActiveQueryMonitors, queryMonitorByWidgetId, queryMonitorsByDashboardId - Fix case sensitivity: use lowercase status values to match SQL constraint - Remove redundant pass statement, simplify wasAlerting/wasWarning with helper * Cache current_value to avoid eval() on every dashboard load - Add current_value column to query_monitors table - Store evaluated value during background job instead of computing on read - Replace eval(log_query_as_sql) with cached current_value in getWidgetAlertStatuses - Remove unnecessary null guard from deleteMonitorsByWidgetIds - Use foldMap for statusMap construction * Simplify monitor status logic and extract updateTabBySlug helper - Refactor monitorStatus to use breached/recovered predicates instead of duplicated comparison logic for triggerLessThan - Use currentStatus field directly instead of time-based alerting checks - Extract updateTabBySlug helper in Dashboards to reduce code duplication * Auto-format code with fourmolu * Consolidate widget alert migrations into single file * Move showThresholdLines from monitor to widget configuration showThresholdLines is a display setting that belongs in the widget JSON, not the monitor database table. This change: - Removes show_threshold_lines column from query_monitors table - Updates widgetAlertUpsertH to save showThresholdLines to the widget - Widget already has this field in its JSON schema * Use DOUBLE PRECISION for threshold and metric values Support decimal values (e.g., 0.5, 32.5°C) in monitor thresholds: - Migration: Convert alert_threshold, warning_threshold to DOUBLE PRECISION - Migration: New columns use DOUBLE PRECISION (recovery thresholds, current_value) - Haskell: Update all threshold/value fields from Int to Double - Remove fromIntegral conversions in BackgroundJobs * Code cleanup: simplify BackgroundJobs and add NOT NULL constraints - Simplify sum/map to list comprehension: sum [v | Only v <- results] - Inline wasAlerting/wasWarning in monitorStatus call - Use void consistently instead of _ <- pattern - Simplify breached/recovered predicates in monitorStatus - Use && instead of , in guards for clarity - Add NOT NULL to current_status and current_value columns * Auto-format code with fourmolu * Fix: remove stale show_threshold_lines from SELECT queries * Fix: rename 'first' variable to avoid shadowing Bifunctor.first * Refactor: use _select from pg-entity instead of manual column lists * Refactor: address code review feedback for alerts-in-widgets - Add MonitorStatus ADT (MSNormal/MSWarning/MSAlerting) replacing string literals - Simplify applyAlertStatus using fromMaybe/do pattern - Add warning log when widget alert query parsing fails - Fix race condition by deleting monitors before dashboard update - Normalize widgetId once at function entry in dashboardWidgetPutH * Auto-format code with fourmolu * Fix: format threshold values with thousand separators * Refactor: extract formatWithCommas to Utils.hs * Refactor: extract shared alert UI helpers to Pages/Monitors.hs - Add thresholdInput_, recoveryInput_, directionSelect_, frequencySelect_, collapsibleSection_ - Update Dashboards.hs widgetAlertConfig_ to use shared helpers - Update Log.hs alertConfigurationForm_ to use shared helpers - Net reduction of ~37 lines through DRY refactoring * Auto-format code with fourmolu * Style: use surface-raised for alert form in Log.hs * Add integration tests and doctests for alert monitoring - Add doctests to monitorStatus for hysteresis logic validation - Add widget alert cascade deletion test - Add widget alert query sync test - Add monitor with recovery thresholds integration test - Export checkTriggeredQueryMonitors and monitorStatus from BackgroundJobs - Fix missing AlertUpsertForm fields in MonitorsSpec * Refactor: extract functions and fix hlint warnings - Extract syncWidgetAlert, normalizeWidget, updateDashboardWidgets from dashboardWidgetPutH - Extract evaluateQueryMonitor with error handling for SQL failures - Fix hlint warnings: use toText, one, and function composition * Auto-format code with fourmolu --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> |
History
|
|
|---|---|---|
| .. | ||
| doctests | ||
| golden | ||
| integration | ||
| unit | ||