Skip to content

Slack — Alert Notifications ​

The CritterWatch.Slack package posts CritterWatch's alert lifecycle to Slack as rich Block Kit messages: raised, elevated, reduced, resolved, cleared, acknowledged, and snoozed. With UseThreads on (the default), lifecycle updates reply in-thread to the original alert message, so one alert is one conversation. When LLM alert triage is on, its assessment replies in the same thread.

The package depends only on the store-agnostic CritterWatch.Services core, so it works with all three console packages: CritterWatch (Marten / PostgreSQL), CritterWatch.SqlServer (Polecat / SQL Server) and CritterWatch.Sqlite (Fisher / SQLite).

bash
dotnet add package CritterWatch.Slack

Configuration ​

Register it on the console host — inside the configureWolverine callback you pass to AddCritterWatch(...), not on the monitored services:

cs
opts.AddCritterWatchSlack(slack =>
{
    // A Slack Bot OAuth token with chat:write scope (required).
    slack.BotToken = Environment.GetEnvironmentVariable("SLACK_BOT_TOKEN")!;

    // Where alert notifications land by default.
    slack.DefaultChannel = "#critterwatch-alerts";

    // Critical-severity alerts can route to a dedicated channel.
    slack.CriticalChannel = "#ops-critical";
});

The bot token is required: AddCritterWatchSlack throws at registration when it is empty. That is the only check — the token is not validated against Slack, so a wrong or revoked token shows up as a logged warning on the first post. Create a Slack app with the chat:write scope, install it to your workspace, and invite the bot to the target channels.

Routing and filtering ​

SlackConfiguration routes and filters notifications:

  • DefaultChannel — where alerts land unless something more specific matches.
  • CriticalChannel — critical-severity alerts route here when set.
  • AlertTypeChannels — pin specific alert types (e.g. "ProjectionLag") to specific channels; takes precedence over both channels above.
  • MinimumSeverity — raised and elevated alerts below this are skipped (default "Warning", i.e. Warning + Critical notify, Info doesn't).
  • UseThreads — lifecycle updates (elevated / resolved / …) reply in the original message's thread (default true); disable to post each event standalone. Where each alert was posted is stored in the console's own database, so a follow-up still replies in-thread after a console restart, and when another node of a clustered console handles it. The record is removed when the alert resolves or is cleared, and after 30 days for an alert that never does.
  • IncludeTriage — post the AI triage assessment as a reply to each alert it covers (default true). Set it to false to keep model output out of Slack.

With threading on, an alert's follow-ups go to the channel its raise was posted to, in the raise's thread, wherever their own routing would have sent them, so an alert's whole lifecycle stays in one conversation. The channel settings decide where a raise lands. With threading off, or for a follow-up to an alert whose raise was not posted here (below MinimumSeverity, or the post failed), each post is routed on its own: only the raise and the resolution consult AlertTypeChannels, only the raise and an elevation or reduction consult CriticalChannel, and clears, acknowledgements and snoozes go to DefaultChannel.

AI triage in Slack ​

When LLM alert triage is enabled on the console, its assessment of a group of alerts is posted as a reply in the thread of each alert it covers, after the assessment has been stored. It is labelled "AI assessment — suggestion only, not a diagnosis", as it is in the console, and carries the summary, the assessment, and any suggested console actions by name. There are no buttons: nothing in Slack runs a command. To act on a suggestion, use the alert's own button in the console, which goes through its RBAC check.

Only alerts this package posted get a reply, so MinimumSeverity and the channel routing apply to triage too. An assessment that covers three alerts posts three replies, one per thread. With UseThreads off, the reply is posted on its own in the channel the alert went to.

Behavior notes ​

  • AddCritterWatchSlack registers an alert notification sink, not Wolverine handlers. The console hands every sink each alert batch after publishing it to the console, on an in-memory queue and delivery loop of its own, so Slack latency never delays alerts reaching the console. Within a batch the changes arrive in order (raised before resolved), which is what lets a follow-up thread under its raise.
  • Posting is best-effort: a Slack API failure is logged as a warning and never disturbs alert evaluation or the console itself. If Slack stops answering for long enough to fill the queue, the newest batches are dropped and the drop is logged.
  • Alerts themselves are evaluated (and license-gated) upstream; this package only renders and delivers what the alerting pipeline produces.
  • For a simpler setup with no package and no bot, the console's own Notification Channels post alerts to a Slack, Discord or Microsoft Teams incoming webhook URL configured in Settings. Those are flat posts with no threading; this package is the one that threads an alert's lifecycle. A generic HTTP webhook channel is not implemented.

Other destinations ​

Slack is one implementation of CritterWatch.Services.Alerts.IAlertNotificationSink, and any other integration can implement it the same way: Task NotifyAsync(AlertChangesBatch batch, CancellationToken token). Register your implementation in the console host's container (opts.Services.AddSingleton<IAlertNotificationSink, MySink>()) and it receives the same batches, in the same order, off the alert path. A sink that throws is logged and skipped; the other sinks still get the batch.

Two optional pieces:

  • NotifyTriagedAsync(AlertTriagedMessage, CancellationToken) receives each stored AI triage narrative, on the same queue as the batches and so after the raise it is about. It does nothing unless you override it.
  • IAlertNotificationThreads, resolvable from the console's container, stores where your sink posted each alert (keyed by a sink name of your choosing), in the console's own database, so your follow-ups can thread across restarts and nodes as Slack's do.