Introducing a new way to review your PRs.

Read the announcement

rajnandan1 / kener

Stunning status pages, batteries included!

View on GitHub

19 documents · Updated Nov 23, 2026

docs / alert-routing-delivery

Alert routing and notification delivery

Alert routing connects a monitor alert to one or more notification targets. It also sends incident and maintenance updates to email subscribers who opt in to those events. Alert state, delivery work, and provider results remain separate so an engineer can inspect the alert record even when a provider request fails. See Alerting and subscriptions for the wider alert lifecycle and Queue scheduling for shared queue behavior.

Routing model

A monitor service produces the monitor result, and the confirmation flow stabilizes status changes before alert routing uses them. An alert configuration defines which monitor condition can create an alert. Linked triggers define where a TRIGGERED or RESOLVED message goes. Subscriber delivery follows a separate path that starts with an incident or maintenance update and ends with individual email jobs.

This diagram shows the two notification paths and their delivery boundaries.

flowchart LR
    A[Monitor result] --> B[Alert configuration]
    B --> C[Alert record]
    C --> D[Linked trigger]
    D --> E[Email, Slack, Discord, or webhook]
    C --> F[Incident comment when configured]
    F --> G[Subscriber queue]
    G --> H[Active event subscribers]
    H --> I[One email job per subscriber]

Direct alert routing

The alert worker loads all triggers linked to the matching configuration. It builds shared alert and site values, renders the selected trigger body, and calls the adapter for that trigger type. One email trigger can address several recipients, while each HTTP-based trigger sends to its configured endpoint.

Direct routing reports provider work separately from alert state. A failed provider request is logged by the worker or adapter; it does not restore the alert to its prior state. Adapter calls do not add their own timeout or retry, so queue policy is the retry boundary.

References: src/…/alertingQueue.ts• L112-165 src/…/alertingQueue.ts• L219-276 src/…/EGM.md• L15-30 src/…/EGM.md• L3-6

Trigger associations

A trigger is a named reusable delivery target. An alert configuration can link several triggers, and the same trigger can serve several alert configurations. This lets teams change a target without changing the condition that starts an alert.

The supported trigger types are email, webhook, slack, and discord. Email uses recipient and sender fields. The other types use a URL and a JSON message body. Generic webhooks can also define custom headers.

References: src/…/+page.svelte• L489-521 src/…/+page.svelte• L312-389 src/…/db.ts• L172-212

Alert configuration

An alert configuration is the rule and routing link for one or more monitors. It defines the condition, the evidence needed to start or resolve an alert, its context, and its direct notification targets.

Alert rule settings

The management form requires at least one monitor. A rule can watch status, latency, or uptime. Its value identifies the condition, while failure and success thresholds require consecutive evidence before the alert starts or resolves.

The rule also stores severity, an optional description, an active flag, and whether to create an incident. The monitor and trigger links are stored separately from the rule fields, so either association can change without replacing the whole configuration.

SettingPurpose
MonitorsSelects the monitor tags covered by the rule.
Alert type and valueDefines a status, latency, or uptime condition.
Failure thresholdSets the consecutive failures needed to trigger.
Success thresholdSets the consecutive recovery checks needed to resolve.
Severity and descriptionAdds context to alert and incident messages.
Create incidentCreates an incident when the first active alert starts.
Notification triggersSelects the direct delivery targets.

References: src/…/+page.svelte• L202-240 src/…/+page.svelte• L304-487 src/…/monitorAlertConfigController.ts• L35-117

Trigger metadata

Each trigger keeps its type-specific settings as one metadata record. The editor starts with a built-in message template, then allows a team to replace the message body with a custom Mustache template. A saved trigger can be tested from the management page before it is linked to an alert rule.

The trigger controller validates email addresses when an email trigger is saved. The management form validates the required URL for non-email targets and the sender format for email targets.

References: src/…/+page.svelte• L78-204 src/…/+page.svelte• L486-521 src/…/triggerController.ts• L5-35 src/…/+server.ts• L310-383

Alert logs

Alert logs are the stored history of alert state for a monitor and configuration pair. They show what state the alert reached and whether it links to an incident. They do not act as delivery receipts for email or endpoint requests.

Log records

The management view paginates logs and filters them by TRIGGERED or RESOLVED. Each row shows the monitor tag, state, creation and update times, and an incident link when one exists. An engineer can update the stored state or delete the record from this view.

Deleting a log removes the alert record. The delete action can also remove its associated incident when the engineer selects that option. It does not send a cancellation message to any target.

References: src/…/+page.svelte• L61-151 src/…/+page.svelte• L216-287 src/…/monitorAlertConfigController.ts• L543-631

Subscriber delivery

Subscribers receive public event updates instead of direct alert-trigger messages. An incident comment is the notification event for incidents; maintenance lifecycle code sends equivalent variable data for maintenances. Maintenance updates carry a stable update ID, an event type, a subject, rendered update text, and a link to the maintenance page.

Subscriber queue

When an incident comment is created, the incident path builds subscription variables and pushes one job to the subscriber queue. The worker loads the general subscription_update email template and selects subscribers whose event subscription, subscriber account, and delivery method are active. The default template is seeded into the stored general email templates, so runtime delivery uses the saved copy. It then creates one email job per unique address so recipients do not share a recipient list. See Queue scheduling for the queue model.

Incident comments use the comment ID as a stable deduplication key. This prevents a repeated push for the same comment from creating a second subscriber notification. The alert worker must not push a second subscriber event for an alert-created incident because its opening or closure comment already drives the subscriber path.

References: src/…/incidentController.ts• L424-453 src/…/subscriberQueue.ts• L30-75 src/…/emailQueue.ts• L33-53 src/…/maintenanceController.ts• L130-151 src/…/notification_utils.ts• L53-90 src/…/subscriptionSystem.ts• L282-345 src/…/EGM.md• L3-23

Subscriber preferences

The current subscriber model supports email as the delivery method and incidents and maintenances as event types. Each event type has its own active or inactive subscription. The public preference path checks the subscriber account and email method before it changes either event preference.

The worker checks active subscriptions when it processes an event, so a disabled preference does not receive a new message. Active subscriber selection also excludes inactive subscriber accounts and delivery methods.

References: src/…/userSubscriptionsController.ts• L389-423 src/…/userSubscriptionsController.ts• L549-618 src/…/userSubscriptionsController.ts• L356-367 src/…/db.ts• L849-920 src/…/subscriptionSystem.ts• L282-345

Subscriber administration

The management page provides a site-wide subscription setting and separate switches for incident and maintenance email updates. It also lets an administrator add an email address with event choices, change each event preference, and remove a subscriber.

Subscriber records use three related concepts: a subscriber user identifies the account, a subscriber method identifies the delivery address, and a subscription connects that method to an event type. Adding a known email reactivates its existing account or method instead of creating a second one. Removing a subscriber deletes its event subscriptions and method, then removes the account when no other method remains.

References: src/…/+page.svelte• L101-171 src/…/+page.svelte• L173-320 src/…/userSubscriptionsController.ts• L134-182 src/…/userSubscriptionsController.ts• L185-258 src/…/userSubscriptionsController.ts• L261-353 src/…/subscriptionSystem.ts• L386-479

Delivery adapters

Delivery adapters turn a saved trigger and event data into a provider request. They replace supported environment-secret references, render Mustache variables, and then send through an email service or an HTTP POST request. They do not retry or set a request timeout themselves; the queue that calls them owns that work.

Shared template data

Alert templates receive alert values and site values. Alert values describe the rule and its state. Site values provide the site name, links, logo, and status colors. Incident ID and incident URL are present only when the alert is linked to an incident.

The shared values cover these groups:

  • Identity: alert ID, name, source, type, value, and timestamp.
  • State: status, severity, message, trigger flag, and resolved flag.
  • Thresholds: failure and success counts.
  • Links: monitor details and the optional incident page.
  • Site context: site URL, site name, logo URL, and status colors.

References: src/…/notification_utils.ts• L9-49 src/…/types.ts• L3-30 src/…/+page.svelte• L392-404

Email delivery

The email adapter renders the subject and HTML body with Mustache. It sends a supplied text body or creates one by removing HTML tags from the rendered HTML. A direct email trigger accepts a comma-separated recipient list and can set its own sender value.

The default alert email uses the site logo and a state badge. It shows the alert state, severity, condition, thresholds, message, and links to the monitor and optional incident. Triggered and resolved alerts use different status colors, while the trigger editor lets a team replace the default HTML without changing the shared variable contract.

References: src/…/email_notification.ts• L10-76 src/…/email_alert_template.ts• L1-157 src/…/+page.svelte• L451-507

SMTP delivery

SMTP is one of the email provider paths. When a complete SMTP configuration is available and Resend is not selected, the email adapter sends through a cached SMTP transport. The configuration supplies the host, port, security mode, login data, and sender address.

The SMTP path can omit authentication when the configured user or password is -. The email setup check treats SMTP or a complete Resend configuration as sufficient for email delivery.

References: src/…/email_notification.ts• L37-71 src/…/smtps.ts• L9-44 src/…/emailController.ts• L13-19 src/…/commonController.ts• L56-77 src/…/EGM.md• L15-30

Webhook delivery

The webhook adapter sends the rendered custom body to the configured URL with an HTTP POST. It adds JSON content headers and a Kener user-agent. Custom headers can replace default values or add new values.

The default webhook template produces a JSON object with alert state, thresholds, links, site context, and optional incident fields. The adapter renders without HTML escaping so the result remains usable as JSON or plain text.

References: src/…/webhook_notification.ts• L7-80 src/…/webhook_alert_template.ts• L1-22 src/…/+page.svelte• L370-408

Slack delivery

The Slack adapter posts a rendered JSON body to the configured Slack webhook URL. Its default template uses Slack Block Kit to show whether the alert triggered or resolved, its key values, an optional incident link, and a monitor action link. The header and action button also use state-specific presentation so a triggered alert stands out from a resolved alert.

Slack uses the same alert and site variable contract as email and webhooks. Teams can replace the default Block Kit payload with a custom Mustache body.

References: src/…/slack_notification.ts• L5-57 src/…/slack_alert_template.ts• L1-107 src/…/+page.svelte• L431-449

Discord delivery

The Discord adapter posts a rendered JSON body to the configured Discord webhook URL. Its default template uses a rich embed with the site identity, alert state, key values, thresholds, links, and a timestamp. The embed also changes its status text and color for triggered and resolved alerts.

Discord uses the same alert and site variable contract as the other direct adapters. Teams can replace the default embed payload with a custom Mustache body.

References: src/…/discord_notification.ts• L5-57 src/…/discord_alert_template.ts• L1-64 src/…/+page.svelte• L411-429

Alert templates

The built-in templates give each target a useful default presentation while preserving one shared event model. Email uses HTML with a state badge, Slack uses Block Kit JSON with state-specific header and action styles, Discord uses embed JSON with state-specific text and color, and webhooks use a general JSON object.

Custom bodies use Mustache placeholders listed by the trigger editor. Email subjects and bodies render as text or HTML. JSON-based targets render without HTML escaping, so custom payloads must remain valid for the receiving service. The general subscriber update template is stored in the database after seeding, so editing its source default does not change an existing stored template.

References: src/…/+page.server.ts• L1-13 src/…/email_alert_template.ts• L1-157 src/…/slack_alert_template.ts• L1-107 src/…/discord_alert_template.ts• L1-64 src/…/webhook_alert_template.ts• L1-22 src/…/EGM.md• L3-25 src/…/EGM.md• L3-23

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep alert variable names aligned across notification_utils.ts, all built-in templates, and the trigger editor help text.
  • Keep each trigger metadata shape aligned across the editor, trigger validation, alert worker, test action, and matching adapter.
  • Preserve the link between alert configurations and triggers when changing trigger deletion or configuration update behavior.
  • Preserve one incident-comment notification path for alert-created incidents to avoid duplicate subscriber email.
  • Keep subscription event names aligned across incident and maintenance producers, subscriber selection, and subscriber preferences.
  • Keep the three subscriber layers aligned: account status, delivery method status, and event subscription status.
  • Keep subscription_update available when changing the subscriber queue or general email template management. Remember that the seeded source is not the runtime copy after the database row exists.
  • Treat changes to email provider selection as changes to both direct alert email and subscriber email delivery.
  • Keep monitor status confirmation upstream of alert routing when changing monitor result or threshold behavior.
  • Keep queue retry and timeout policy explicit when changing adapter behavior because adapters do not provide their own retry or timeout.

Important failure modes

TriggerConsequenceGuard
Alert configuration has no linked triggerAlert state changes but no direct target receives a messageLink an active trigger to the configuration.
Trigger metadata does not match its trigger typeThe worker can fail before it sends or build an invalid provider requestUpdate the editor, validator, worker, and adapter as one contract.
SMTP or Resend is not fully configuredEmail jobs fail instead of sendingProvide a complete SMTP setup or both Resend API key and sender address.
Custom JSON body or headers are invalidThe endpoint can reject the request or custom headers can be ignoredValidate the payload and use the trigger test before enabling the alert.
subscription_update is missing or its stored copy is staleSubscriber jobs stop or send outdated contentKeep the template seeded and update the stored template when its contract changes.
Subscriber event is inactiveThe event produces no email for that subscriberEnable the matching incident or maintenance preference.
Subscriber account or method is inactiveThe event is excluded even when the event subscription is activeKeep the subscriber account and email method active.
Alert-created incident sends a second subscriber pushSubscribers receive duplicate incident messagesUse the incident comment as the only subscriber event.
Adapter request fails without queue retry policyA provider failure is logged but the notification is not retriedConfigure the owning queue's retry behavior.

Key files

FileWhy to read it
src/…/alertingQueue.tsShows alert-to-trigger routing and the direct delivery sequence.
src/…/service.tsShows how monitor results enter the alerting path.
src/…/confirmationThreshold.tsShows how repeated monitor results become a stable status change.
src/…/monitorAlertConfigController.tsDefines alert configuration validation and alert record operations.
src/…/+page.svelteShows the product-facing alert rule and trigger selection.
src/…/+page.svelteShows alert log filters and management actions.
src/…/+page.svelteShows trigger types, fields, custom bodies, and test behavior.
src/…/incidentController.tsShows how incident comments become subscriber events.
src/…/notification_utils.tsDefines alert and maintenance values used by notification templates.
src/…/subscriptionSystem.tsShows the account, delivery method, and event subscription relationships.
src/…/userSubscriptionsController.tsShows subscriber preference and administrator actions.
src/…/+page.svelteShows subscription settings and subscriber management.
src/…/subscriberQueue.tsShows subscriber selection and the handoff to per-recipient email jobs.
src/…/emailQueue.tsShows the final queued email send step.
src/…/email_notification.tsShows shared email rendering and provider selection.
src/…/smtps.tsShows SMTP transport creation and reuse.
src/…/webhook_notification.tsShows generic HTTP webhook rendering and request handling.
src/…/slack_notification.tsShows Slack webhook delivery.
src/…/discord_notification.tsShows Discord webhook delivery.
src/…/email_alert_template.tsShows the default HTML alert email and state presentation.
src/…/slack_alert_template.tsShows the default Slack Block Kit payload and state presentation.
src/…/discord_alert_template.tsShows the default Discord embed payload and state presentation.
src/…/webhook_alert_template.tsShows the default generic webhook JSON payload.
src/…/subscription_update_template.tsShows the default subscriber update email before it is stored in the database.