Skip to content

Alert channels

Gjallarhorn can announce findings on several channels at once. Each entry under channels: has a type, a unique name, the realms it covers (empty = all) and a min_severity. Routing and the immediate-versus-digest rules are the same for every type (see Alert rules); only the message format and the delivery differ.

realms: [prod, dev]
channels:
- type: slack
name: dev-chat
webhook_env: SLACK_WEBHOOK_DEV
realms: [dev]
min_severity: high
- type: pagerduty
name: oncall
routing_key_env: PAGERDUTY_ROUTING_KEY
realms: [prod]
min_severity: critical
- type: email
name: security-team
host: smtp.example.com
from: Heimdall <heimdall@example.com>
to: [security@example.com]
username_env: SMTP_USERNAME
password_env: SMTP_PASSWORD
min_severity: high
  • One alert per advisory or release per channel. A channel only sees the findings of the realms it covers, and only when the alert reaches its min_severity (releases, end of support and Kubernetes CVEs count as high).
  • The existing teams: list keeps working. Its routes are Teams channels; teams: and channels: can be used together, and names must be unique across both. type: teams under channels: is the same thing.
  • A realm is covered when any Teams route or channel covers it. Findings of an uncovered realm stay pending (one warning in the logs) and go out once a channel covers the realm.
  • The weekly digest and the first-run summary go to every channel covering the realm whose digest is on, whatever its min_severity. digest defaults to true, except for the paging types (pagerduty, alertmanager), where a weekly summary would page someone; set digest: true there to opt in, or digest: false on any channel to opt out. Medium and low findings of a realm that no digest channel covers stay pending until one does.
  • Links: only links Heimdall makes itself (the advisory, the release notes) are clickable. Text that comes from upstream, such as release-note lines in the digest, is always shown as escaped plain text, so a Markdown link in it never becomes a link in any channel.
  • Delivery goes through the database outbox: about one message every 2 seconds, retries with a growing delay (30 s doubling to 1 h), Retry-After honoured (clamped to 1 h), exactly once even across restarts. A message the channel rejects (a 4xx other than 429, a permanent SMTP error) is not retried and counts in heimdall_notify_failures_total{channel_type}.
  • A missing variable keeps that channel’s messages queued until it is set. Renaming a channel to another type leaves messages queued for the old type where they are, rather than sending them in the wrong format.

Every type accepts name, type, realms, min_severity and digest. Unknown keys are an error, so a key of another type (say chat_id on Slack) is caught at startup.

type: teams, webhook_env. Adaptive Cards through a Workflows webhook; see Microsoft Teams alerts for setting up the webhook.

type: slack, webhook_env (an incoming webhook URL). Messages use Block Kit: a header, the severity and realm, the findings, and buttons for the advisory and release notes.

- type: slack
name: team
webhook_env: SLACK_WEBHOOK_TEAM
min_severity: high

type: discord, webhook_env (a channel webhook URL: Channel settings → Integrations → Webhooks). One embed per message, coloured by severity. Text is Markdown-escaped and mentions are disabled, so an advisory saying @everyone pings nobody.

type: telegram, bot_token_env (a bot token from BotFather), chat_id (a number such as -1001234567890, or @channelname), and optionally api_url (default https://api.telegram.org, for a Bot API proxy). Messages use HTML parse mode with every piece of text escaped. The token sits in the request path, so Heimdall redacts it from every error it logs.

- type: telegram
name: ops-chat
bot_token_env: TELEGRAM_BOT_TOKEN
chat_id: -1001234567890
min_severity: high

type: pagerduty, routing_key_env (the integration key of an Events API v2 integration), optionally url (default https://events.pagerduty.com/v2/enqueue; use https://events.eu.pagerduty.com/v2/enqueue for EU accounts). Each alert is a trigger event whose dedup_key is the alert’s key (alert|vuln|GHSA-…), so a later alert for the same advisory joins the open incident. Severity maps critical → critical, high → error, medium → warning, the rest → info. Heimdall does not send resolve events.

type: alertmanager, url (the base URL; alerts are POSTed to {url}/api/v2/alerts), optional basic auth (username_env and password_env) or bearer token (bearer_token_env), and expire_after_hours (default 24).

Each finding becomes one Alertmanager alert, so you can route, group and silence on its labels:

Label Value
alertname Heimdall + kind: HeimdallVuln, HeimdallFixAvailable, HeimdallMajorRelease, HeimdallOathExpired, HeimdallEol, HeimdallK8sCve, HeimdallReleaseNoteCve (and HeimdallFirstRun, HeimdallDigest when the channel sets digest: true)
realm The finding’s realm
service The service, when the finding has one
kind vuln, fixavailable, majorrelease, …
severity critical, high, medium, low, unknown; info for the digest and summary
advisory The advisory id, for advisory kinds

Annotations: summary (the title), description (the finding’s facts) and links (one URL per line); generatorURL is the advisory or release notes.

- type: alertmanager
name: am
url: http://alertmanager.monitoring:9093
expire_after_hours: 24
min_severity: high

type: webhook, url_env (the URL to POST to) and optionally secret_env. The body is the neutral alert model as JSON:

{
"version": 1,
"alert": {
"key": "alert|vuln|GHSA-gin-0001",
"kind": "vuln",
"title": "⚠ GHSA-gin-0001 (high) affects 2 service(s)",
"severity": "high",
"realm": null,
"advisory": "GHSA-gin-0001",
"summary": "gin mishandles header parsing",
"scores": "OSV 7.5 · NVD 9.8",
"notes": [],
"facts": [],
"entries": [
{"finding_id": 1, "realm": "prod", "service": "api", "severity": "high",
"facts": [{"title": "Component", "value": "pkg:golang/github.com/gin-gonic/gin@v1.9.0"}]}
],
"sections": [],
"links": [{"title": "Open GHSA-gin-0001", "url": "https://osv.dev/vulnerability/GHSA-gin-0001"}]
}
}

kind is a finding kind, firstrun or digest. Each section line is {"link": {"title", "url"} | null, "text": "..."}: link is a link Heimdall made (a release’s notes), text may come from upstream and should be shown as plain text.

Every request carries X-Heimdall-Timestamp (Unix seconds, the send time). With secret_env, it also carries X-Heimdall-Signature: sha256=<hex>: the HMAC-SHA256, keyed with the secret, of the timestamp, a dot and the raw request body ("{timestamp}.{body}"). Verify it over the bytes you received, before parsing, with a constant-time comparison, and reject requests whose timestamp is more than 5 minutes off, so a captured request cannot be replayed later:

import hashlib, hmac, time
def verify(secret: bytes, headers, body: bytes, tolerance: int = 300) -> bool:
ts = headers.get("X-Heimdall-Timestamp", "")
if not ts.isdigit() or abs(time.time() - int(ts)) > tolerance:
return False
signed = ts.encode() + b"." + body
expected = "sha256=" + hmac.new(secret, signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, headers.get("X-Heimdall-Signature", ""))

A message may be delivered again only if your endpoint answered with an error; use alert.key to drop duplicates.

type: email sends through an SMTP server, in plain text and simple HTML.

Key Meaning
host SMTP server.
port Default by security: 587, 465 or 25.
security starttls (default; STARTTLS is required, never opportunistic), tls (implicit TLS) or none (only for a relay on a trusted network).
username_env, password_env Variables holding the SMTP login (set both or neither). Not allowed with security: none, which would send the password in clear text.
from Sender, Name <address> or address.
to Recipients (at least one).
- type: email
name: security-team
host: smtp.example.com
security: starttls
username_env: SMTP_USERNAME
password_env: SMTP_PASSWORD
from: Heimdall <heimdall@example.com>
to: [security@example.com, oncall@example.com]
min_severity: high

A temporary failure (a 4xx reply, a network or TLS error) is retried; a permanent one (a 5xx reply such as an unknown recipient) is not. A failed login (530, 534, 535) is a problem with the channel, not the message: the whole channel’s queue waits and retries with the usual backoff, so a wrong password delays mail but never discards it. Fix the credentials and the backlog goes out.

Watch heimdall_outbox_pending (messages waiting) and heimdall_notify_failures_total{channel_type} (messages a channel rejected). The logs name the channel and its type for every failed send, and warn once when a channel’s variable is not set. See Metrics.

Queued messages belong to a channel name and type. If you remove a channel, rename it, or change its type, its unsent messages are never sent, and Heimdall logs one warning per name and type naming them (“outbox has unsent … alerts for channel X, which is no longer configured”). Either restore the channel, or clear them in the database:

-- See what is stuck.
SELECT route, channel_type, count(*) FROM outbox
WHERE sent_at IS NULL GROUP BY 1, 2;
-- Drop the unsent messages of a channel that is gone.
DELETE FROM outbox
WHERE sent_at IS NULL AND route = 'old-name' AND channel_type = 'slack';

Sent rows are removed after retention.outbox_days as usual.