Feature/dlq external alerts#169
Merged
robertocarlous merged 7 commits intoJun 16, 2026
Merged
Conversation
- Create new AlertingService with singleton pattern - Support LOG, SLACK, and PAGERDUTY channels - Implement alert deduplication/cooldown (15 min default) - Support rich DLQ alert payloads with metadata - Export types for DLQAlertPayload
- New gauge tracks whether DLQ alert is currently active - Set to 1 when threshold exceeded, 0 when normalized - Useful for monitoring alert state in Prometheus/Grafana
- DLQ_ALERT_COOLDOWN_MS: Control alert deduplication window (default 15min) - Support SLACK_WEBHOOK_URL for Slack integration - Support PAGERDUTY_ROUTING_KEY for PagerDuty integration - Add ADMIN_DASHBOARD_URL for inspection links
Replace hardcoded SIZE_ALERT_THRESHOLD with configurable config.dlq.alertThreshold - Emit rich DLQ alerts with metadata (size, status breakdown, oldest event age) - Include actionable admin dashboard links - Support alert deduplication to prevent fatigue - Calculate status breakdown (pending, retried, resolved counts) - Track oldest pending event and human-readable age - Clear alert state when queue normalizes Closes Neurowealth#163
Add documentation for: - DLQ_ALERT_COOLDOWN_MS - SLACK_WEBHOOK_URL - PAGERDUTY_ROUTING_KEY - ADMIN_DASHBOARD_URL
- Test AlertingService singleton pattern - Test cooldown/deduplication behavior - Test alert suppression within cooldown window - Test alert re-emission after cooldown expires - Test DLQ alert payload formatting - Test all alert severity levels (critical, warning, info) - Test LOG channel always enabled - Test alert state clearing
Complete guide for handling DLQ alerts: - Inspection and diagnosis steps - Common root causes and recovery procedures - Manual retry procedures - Integration setup (Slack, PagerDuty) - Prometheus monitoring examples - Prevention best practices - Escalation procedures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DLQ External Alerting Implementation
Summary
Wires DLQ size alerts to Slack/PagerDuty with configurable thresholds and deduplication. Replaces hardcoded logging with a pluggable AlertingService supporting multiple notification channels.
Changes
Core Implementation
src/services/alerting.ts): New singleton service with support for LOG, SLACK, and PAGERDUTY channelssrc/stellar/dlq.ts): Replaced hardcoded threshold with config-driven alertingconfig.dlq.alertThresholdfrom environmentConfiguration
.env.example):DLQ_ALERT_THRESHOLD: Queue size alert threshold (default: 50)DLQ_ALERT_COOLDOWN_MS: Deduplication window (default: 15 min)SLACK_WEBHOOK_URL: Optional Slack integrationPAGERDUTY_ROUTING_KEY: Optional PagerDuty integrationADMIN_DASHBOARD_URL: Admin console URL for inspection linksObservability
src/utils/metrics.ts): Newdlq_alert_activegaugeTesting & Documentation
Unit Tests (
tests/unit/stellar/dlq-alerts.test.ts): Comprehensive test coverageRunbook (
docs/DLQ_ALERTING_RUNBOOK.md): Operator guideAcceptance Criteria Met
✅
DLQ_ALERT_THRESHOLDfrom env is the single source of truth✅ Crossing threshold triggers external notification (Slack/PagerDuty) when configured
✅ Alert includes actionable metadata (size, status breakdown, oldest pending age, admin link)
✅ Cooldown prevents duplicate alerts within configured window
✅ Unit tests for threshold logic and cooldown behavior
✅ Runbook section: "What to do when DLQ alert fires" with inspect → dry-run retry → resolve workflow
Backward Compatibility
✅ Fully backward compatible
Closes #163