Skip to content

feat: sink health monitoring — database schema & migrations (Issue #1)#12

Open
joejohnson123[bot] wants to merge 1 commit into
mainfrom
jj/sink-health-monitoring-schema
Open

feat: sink health monitoring — database schema & migrations (Issue #1)#12
joejohnson123[bot] wants to merge 1 commit into
mainfrom
jj/sink-health-monitoring-schema

Conversation

@joejohnson123

@joejohnson123 joejohnson123 Bot commented Feb 26, 2026

Copy link
Copy Markdown

What

Implements Issue #1 — foundational database tables and Ecto schemas for the sink health monitoring feature.

This is the first PR in the sink health monitoring series. All subsequent work (evaluation worker, notification dispatcher, UI, etc.) builds on these schemas.

New Tables (all in config_schema)

sink_monitors

Per-sink monitor configuration. Supports two types:

  • Threshold: fires when metric ≥ value for a sustained window
  • Anomaly: fires when metric deviates statistically from rolling average

Fields: name, enabled, metric (pending/failed messages), monitor_type, threshold_value, threshold_window_seconds, anomaly_sensitivity (low/medium/high), notify_on_recovery, cooldown_seconds

Unique constraint on (sink_consumer_id, name).

sink_monitor_notification_channels

Alert destinations per monitor. Supports: webhook, Slack, Discord, PagerDuty, Incident.io.

Config is encrypted via Sequin.Encrypted.Map. Each channel type has validation for required config fields (e.g. webhook requires url, Slack requires webhook_url).

sink_monitor_alerts

Alert history — tracks triggered and resolved incidents with metric values and timestamps.

sink_monitor_metric_samples

Rolling metric snapshots for anomaly detection (auto-pruned to 2 hours).

Schemas

All 4 schemas follow existing Sequin patterns:

  • use Sequin.ConfigSchema + typed_schema
  • Ecto.Enum for enum fields
  • Changeset validation with type-specific field requirements
  • Query helpers (where_account_id, where_enabled, etc.)

Build Note

⚠️ Could not run mix compile --warnings-as-errors in the sandbox environment (thread/process limits prevent native NIF compilation for ezstd, crc32cer, argon2_elixir). Schemas follow all existing conventions exactly — please verify compilation locally.

Closes

Closes #1


Summary by cubic

Introduces the database schema and Ecto models for sink health monitoring (Issue #1). Establishes monitors, alerts, metric samples, and notification channels as the foundation for evaluation, notifications, and UI.

  • New Features

    • New tables (config_schema): sink_monitors, sink_monitor_notification_channels, sink_monitor_alerts, sink_monitor_metric_samples.
    • Monitors: threshold or anomaly on pending/failed metrics; validations; unique name per sink; cooldown and recovery options.
    • Channels: webhook, Slack, Discord, PagerDuty, Incident.io with encrypted config and per-type validation.
    • Alerts: triggered/resolved status with timestamps; metric samples for anomaly detection.
    • Schemas use enums and include simple query helpers.
  • Migration

    • Run migrations to create enum types, tables, and indexes under config_schema.

Written for commit a1bf6c7. Summary will update on new commits.

Implements Issue #1 — foundational tables and Ecto schemas for sink
health monitoring.

New tables (all in config_schema):
- sink_monitors: per-sink monitor config (threshold or anomaly type)
- sink_monitor_notification_channels: alert destinations (webhook/slack/discord/pagerduty/incident_io)
- sink_monitor_alerts: alert history (triggered/resolved)
- sink_monitor_metric_samples: rolling metric data for anomaly detection

Schemas include:
- Full changeset validation with type-specific field requirements
- Threshold monitors require threshold_value + window_seconds
- Anomaly monitors require sensitivity level (low/medium/high)
- Channel config validation per channel type (url/webhook_url/routing_key/api_key)
- Encrypted channel config via Sequin.Encrypted.Map
- Query helpers for common access patterns

Co-authored-by: Joe Johnson (JJ) <joejohnson123[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

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.

Sink Health Monitoring: Database Schema & Migrations

1 participant