Skip to content

🎯 Bounty: Uptime Monitoring Alarm Integration #268

@izadoesdev

Description

@izadoesdev

🎯 Bounty: Uptime Monitoring Alarm Integration

Bounty: $15

Depends on: #267 (Alarms System)

Overview

Integrate the alarms system with uptime monitoring to trigger notifications when a site goes down or comes back up. Users should be able to assign alarms to their monitored websites and receive notifications via their configured channels (Slack, Discord, Email, Webhook, Teams, Telegram, Google Chat).

Requirements

1. Uptime Trigger Integration (Required)

Connect the uptime monitoring service to the alarms system.

Trigger Events:

  • Site goes down (consecutive failures threshold met)
  • Site comes back up (recovery)
  • Response time exceeds threshold (optional/stretch)

Acceptance Criteria:

  • Uptime service checks for alarms assigned to the website
  • Triggers alarm when site status changes (up → down, down → up)
  • Respects configurable thresholds (e.g., alert after X consecutive failures)
  • Prevents duplicate notifications (don't spam on every check)
  • Logs alarm trigger history

2. Alarm Assignment UI (Required)

Allow users to assign alarms to monitored websites.

UI Requirements:

  • Uptime monitoring page shows assigned alarms
  • Quick-assign dropdown to add existing alarms
  • Option to create new alarm directly from uptime page
  • Visual indicator showing which alarms are active

Acceptance Criteria:

  • Alarm assignment UI in uptime monitoring section
  • Matches existing dashboard design patterns
  • Mobile responsive
  • Uses existing UI components

3. Notification Content (Required)

Send rich, informative notifications when alarms trigger.

Down Notification Content:

  • Website URL
  • Time detected
  • HTTP status code (if available)
  • Response time (if available)
  • Number of consecutive failures
  • Link to uptime dashboard

Up Notification Content:

  • Website URL
  • Time recovered
  • Downtime duration
  • Link to uptime dashboard

Acceptance Criteria:

  • Uses @databuddy/notifications package helpers
  • Notifications include all relevant site details
  • Channel-specific formatting (Slack blocks, Discord embeds, Teams Adaptive Cards, Telegram HTML, Google Chat cards, HTML email)
  • Professional, clean design matching Databuddy branding

4. Testing (Required)

Acceptance Criteria:

  • Unit tests for alarm trigger logic
  • Test threshold behavior (only trigger after X failures)
  • Test duplicate prevention (no spam)
  • Test both down and up notifications
  • Test multi-channel delivery

Technical Requirements

  • Follow existing codebase patterns in apps/uptime/
  • Use @databuddy/notifications package for sending notifications
  • TypeScript with strict types (no any, unknown, or never)
  • Use dayjs for time calculations and formatting
  • Proper error handling (don't crash uptime service on notification failure)

Files to Reference

  • apps/uptime/src/ - Uptime monitoring service
  • packages/notifications/ - Notification providers and helpers
  • packages/notifications/README.md - Full API reference with all 7 channels
  • packages/db/src/drizzle/schema.ts - Database schema (alarms table from 🎯 Bounty: Alarms System - Database, API & Dashboard UI #267)
  • apps/dashboard/app/(main)/websites/[id]/uptime/ - Uptime dashboard UI

Available Notification Channels

Channel Helper Function Config
Slack sendSlackWebhook(webhookUrl, payload) webhookUrl
Discord sendDiscordWebhook(webhookUrl, payload) webhookUrl
Email sendEmail(sendEmailAction, payload) sendEmailAction, defaultTo
Webhook sendWebhook(url, payload) url, method, headers
Teams sendTeamsWebhook(webhookUrl, payload) webhookUrl
Telegram sendTelegramMessage(botToken, chatId, payload) botToken, chatId
Google Chat sendGoogleChatWebhook(webhookUrl, payload) webhookUrl

Example Usage

import { sendSlackWebhook, sendTeamsWebhook, sendTelegramMessage } from "@databuddy/notifications";

// When site goes down - send to all configured channels
await sendSlackWebhook(alarm.slack_webhook_url, {
  title: "🔴 Site Down: example.com",
  message: "Your website is not responding.",
  priority: "urgent",
  metadata: {
    url: "https://example.com",
    status: 503,
    downSince: "2 minutes ago",
    consecutiveFailures: 3,
  },
});

await sendTeamsWebhook(alarm.teams_webhook_url, {
  title: "🔴 Site Down: example.com",
  message: "Your website is not responding.",
  priority: "urgent",
  metadata: {
    url: "https://example.com",
    status: 503,
    downSince: "2 minutes ago",
  },
});

await sendTelegramMessage(alarm.telegram_bot_token, alarm.telegram_chat_id, {
  title: "🔴 Site Down: example.com",
  message: "Your website is not responding.",
  priority: "urgent",
  metadata: { url: "https://example.com", status: 503 },
});

// Or use NotificationClient for multi-channel in one call
import { NotificationClient } from "@databuddy/notifications";

const client = new NotificationClient({
  slack: { webhookUrl: alarm.slack_webhook_url },
  discord: { webhookUrl: alarm.discord_webhook_url },
  teams: { webhookUrl: alarm.teams_webhook_url },
  telegram: { botToken: alarm.telegram_bot_token, chatId: alarm.telegram_chat_id },
  defaultChannels: alarm.notification_channels,
  defaultRetries: 2,
});

await client.send({
  title: "🟢 Site Recovered: example.com",
  message: "Your website is back online.",
  priority: "normal",
  metadata: {
    url: "https://example.com",
    downtimeDuration: "5 minutes",
    recoveredAt: new Date().toISOString(),
  },
});

Submission Requirements

  • All code follows linting rules (run bun run lint)
  • Type checks pass (run bun run check-types)
  • Tests pass
  • PR includes screenshots of notification examples
  • PR description explains implementation choices

Questions?

Comment on this issue for any clarification needed before starting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions