Skip to content

Port baseline engine and anomaly detection to Dashboard#793

Merged
erikdarlingdata merged 3 commits intodevfrom
feature/dashboard-baseline-port
Apr 7, 2026
Merged

Port baseline engine and anomaly detection to Dashboard#793
erikdarlingdata merged 3 commits intodevfrom
feature/dashboard-baseline-port

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Port time-bucketed baseline engine from Lite to Dashboard (SqlServerBaselineProvider) with SQL Server collect.* tables, @@DATEFIRST normalization, CTE restart exclusion
  • Upgrade SqlServerAnomalyDetector to time-bucketed baselines + 3 new detectors (batch requests, sessions, query duration)
  • Port correlated timeline lanes UI: baseline bands, anomaly dots, Compare dropdown with ghost line overlay
  • Port crosshair manager: ▲/▼ indicators, event-based spike detection for blocking/deadlocks
  • Fix pre-existing CPU tooltip bug (DESC sort vs ASC binary search)
  • Cross-server validated on sql2016–sql2025, all baseline queries < 250ms

Test plan

  • Build succeeds with 0 errors
  • Cross-server validation: DATEPART, STDEV, @@DATEFIRST consistent on sql2016–sql2025
  • Baseline query performance < 2s on sql2016 (measured < 250ms)
  • CPU tooltip shows correct values (OrderBy fix)
  • Wait stats ▲ indicators during spikes
  • Blocking/deadlock ▲ indicators during storms (event-based detection)
  • Compare dropdown scoped to Server Trends sub-tab
  • No auto-refresh chart flicker

🤖 Generated with Claude Code

erikdarlingdata and others added 3 commits April 6, 2026 18:50
Changes across Dashboard, Lite, and InstallerGui:
- ForegroundDimColor now matches ForegroundColor in all 6 themes
- InstallerGui ForegroundMutedBrush changed to foreground color
- ScottPlot chart text colors (#9DA5B4, #4A5568, #364D61) replaced
  with foreground equivalents (#E4E6EB, #1A1D23, #1A2A3A)
- SlicerLabelBrush changed from 60% opacity to full opacity
- Email template text changed from #808080 to #E4E6EB
- Removed Opacity="0.45" from empty-state icons in ServerTab

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 1-3 of the baselines plan for Lite:

Engine:
- BaselineProvider: 30-day rolling baselines bucketed by hour-of-day x day-of-week
  with bucket collapse (full → hour-only → flat) and hysteresis (10/15 thresholds)
- Restart poisoning exclusion for cumulative metrics (batch requests, wait stats,
  query duration) using QUALIFY + LAG heuristic in DuckDB
- 4 existing anomaly detectors upgraded from flat 24h lookback to time-bucketed
- 4 new detectors: batch requests/sec, session counts, query duration, memory
- Per-metric configurable deviation thresholds (default 2σ)
- Proportional stddev floor (max(stddev, mean*0.01)) for division-by-zero
- Fix BigInteger cast error on DuckDB SUM() for session/query duration detectors

MCP:
- analyze_server: baseline context in anomaly findings output
- compare_analysis: updated description noting time-bucketed baselines
- Anomaly fact metadata includes baseline_hour, baseline_dow, baseline_tier

UI (Overview tab):
- Baseline bands (mean ± 2σ) on CPU, Wait Stats, I/O Latency, Blocking lanes
- Red anomaly dots for values outside band (with absolute minimum thresholds)
- Tooltip ▲/▼ indicators (colored red/green) for anomalous values
- "Compare to" dropdown: overlay yesterday/last week as dashed ghost lines
- Right-side value labels removed, charts expanded to full width
- Memory lane renamed to "Buffer Pool MB"
- Blocking/Deadlocks shown on separate lines in tooltip

Tests:
- 15 BaselineProvider tests (buckets, collapse, hysteresis, restart poisoning,
  division-by-zero, cache, server isolation, memory)
- 10 AnomalyDetector tests (all new detectors, per-metric thresholds, metadata)
- 257/257 total tests passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add SqlServerBaselineProvider: time-bucketed baselines from SQL Server
  collect.* tables with @@DATEFIRST normalization, CTE restart exclusion,
  bucket collapse hierarchy (full → hour-only → flat), 1-hour TTL cache
- Upgrade SqlServerAnomalyDetector: inject baseline provider, upgrade 4
  existing detectors to time-bucketed baselines, add 3 new detectors
  (batch requests, sessions, query duration)
- Update FactScorer: score ANOMALY_BATCH_REQUESTS, ANOMALY_SESSION_SPIKE,
  ANOMALY_QUERY_DURATION (deviation-based)
- Port correlated timeline lanes UI: baseline bands, anomaly dots,
  Compare dropdown with ghost line overlay, remove right-side value labels,
  rename Memory MB → Buffer Pool MB, fix auto-refresh flicker
- Port crosshair manager: ▲/▼ baseline indicators, comparison label,
  event-based spike detection for blocking/deadlocks
- Fix pre-existing CPU tooltip bug: data returned DESC, binary search
  assumed ASC — added OrderBy
- Fix event-based baseline: use wait_stats spine for zero-inclusive
  baselines, handle zero-mean EffectiveStdDev for event metrics
- Cross-server validated on sql2016–sql2025, all queries < 250ms

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 4c4602e into dev Apr 7, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/dashboard-baseline-port branch April 9, 2026 00:32
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.

1 participant