Skip to main content

Notification

The Notification CRD allows you to configure notification channels and rules for alerts, incidents, and other events in Mission Control.

Definition

apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: example-notification
spec:
# Type of notification channel
type: slack

# Selector for events to match
selector:
severity: critical
labels:
service: api

# Channel-specific configuration
slack:
channel: "#alerts"
username: "Mission Control"
icon: ":warning:"

# Templates for notification content
templates:
title: "Critical Alert: {{.alert.name}}"
body: "Service: {{.component.name}}\nStatus: {{.status}}\nMessage: {{.message}}"

Schema

The Notification resource supports the following fields:

FieldDescription
spec.typeType of notification channel (slack, email, teams, webhook, etc.)
spec.selectorSelector for matching events to notify about
spec.selector.severitySeverity level to match (critical, high, medium, low)
spec.selector.statusStatus to match (healthy, unhealthy, warning, etc.)
spec.selector.labelsLabels to match on events
spec.selector.componentsComponents to match
spec.selector.expressionCEL expression for complex matching
spec.templatesTemplates for notification content
spec.templates.titleTemplate for notification title
spec.templates.bodyTemplate for notification body
spec.templates.buttonTemplate for notification action button
spec.templates.footerTemplate for notification footer
spec.slackSlack-specific configuration
spec.emailEmail-specific configuration
spec.teamsMicrosoft Teams-specific configuration
spec.webhookWebhook-specific configuration
spec.pagerdutyPagerDuty-specific configuration
spec.connectionReference to a Connection resource
spec.throttleThrottling configuration
spec.throttle.periodTime period for throttling (e.g., 1h, 24h)
spec.throttle.countMaximum number of notifications in the period

Notification Channel Types

The Notification CRD supports various channel types:

TypeDescription
slackSlack channel notifications
emailEmail notifications
teamsMicrosoft Teams notifications
webhookCustom webhook notifications
pagerdutyPagerDuty incidents
smsSMS text messages
discordDiscord notifications
telegramTelegram messages

Examples

Slack Channel for Critical Alerts

apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: critical-alerts-slack
spec:
type: slack
selector:
severity: critical
slack:
channel: "#critical-alerts"
username: "Alert Bot"
icon: ":rotating_light:"
templates:
title: ":red_circle: CRITICAL ALERT: {{.alert.name}}"
body: |
*Component:* {{.component.name}}
*Status:* {{.status}}
*Time:* {{.time | formatTime "Jan 02, 15:04:05 MST"}}
*Details:* {{.message}}

{{if .runbook}}*Runbook:* {{.runbook}}{{end}}

Email Notifications for Production Components

apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: production-email-alerts
spec:
type: email
selector:
labels:
environment: production
email:
to:
- "ops-team@example.com"
- "{{.component.owner}}@example.com"
from: "mission-control@example.com"
subject: "[{{.severity | upper}}] Alert: {{.alert.name}}"
templates:
body: |
<h2>Alert: {{.alert.name}}</h2>
<p><strong>Component:</strong> {{.component.name}}</p>
<p><strong>Status:</strong> {{.status}}</p>
<p><strong>Time:</strong> {{.time | formatTime "Jan 02, 15:04:05 MST"}}</p>
<p><strong>Details:</strong> {{.message}}</p>

{{if .dashboard}}<p><a href="{{.dashboard}}">View Dashboard</a></p>{{end}}
throttle:
period: 1h
count: 10

Microsoft Teams Notification with Adaptive Card

apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: teams-notifications
spec:
type: teams
selector:
severity:
- high
- critical
teams:
webhookUrl: "https://outlook.office.com/webhook/..."
templates:
title: "{{.severity | title}} Alert: {{.alert.name}}"
body: |
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "{{.severity | title}} Alert: {{.alert.name}}"
},
{
"type": "FactSet",
"facts": [
{
"title": "Component",
"value": "{{.component.name}}"
},
{
"title": "Status",
"value": "{{.status}}"
},
{
"title": "Time",
"value": "{{.time | formatTime 'Jan 02, 15:04:05 MST'}}"
}
]
},
{
"type": "TextBlock",
"text": "{{.message}}",
"wrap": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "View Component",
"url": "{{.component.url}}"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2"
}

PagerDuty Integration with Connection

apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: pagerduty-critical
spec:
type: pagerduty
selector:
severity: critical
expression: "component.labels.tier == 'production' && status == 'unhealthy'"
connection: pagerduty-service
templates:
title: "{{.component.name}} - {{.alert.name}}"
body: "{{.message}}"
pagerduty:
severity: critical
component: "{{.component.name}}"
group: "{{.component.labels.team}}"
class: "{{.alert.labels.type}}"

See Also