Notifications
Mission Control provides a flexible, event-based notification system that enables filtering and templating of notifications via email, push, slack, teams, etc.
Notifications are triggered by events. An event is a specific occurrence or change in state within the system. For example, notifications can be granular such as a health check failing or a pod crashlooping - or high level based on the health of the system as a whole.
check-failed.yamlapiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: http-check
namespace: default
spec:
events:
- check.failed
to:
email: alerts@acme.com
This notification will send an email to alerts@acme.com
whenever a health check fails.
Field | Description | Scheme | Template Env |
---|---|---|---|
events* | A list of events that should trigger this notification | ||
body | Channel dependent e.g. email body for email | ||
filter | Filter narrows down the event trigger. Example: | ||
repeatGroup | RepeatGroup allows notifications to be grouped by certain set of keys and only send one per group within the specified repeat interval. Valid group keys: |
| |
repeatInterval | The waiting time to resend a notification after it has been succefully sent. | ||
title | Channel dependent e.g. subject for email | ||
to.connection | Connection to external service | ||
to.email | Send an email to any email address |
| |
to.person | Send an email to the person |
| |
to.properties | Properties are channel dependent special directives to modify the notification message. Example: for email, |
| |
to.team | Send an email to every person in the team |
| |
to.url | Custom notification URL | ||
waitFor | The duration to delay sending a health-based notification. After this period, the health status is reassessed to confirm it hasn't changed, helping prevent false alarms from transient issues. |
Only one recipient can be specified
Templating
You can use Go Templates to customize the content of notification titles and bodies. This allows you to include dynamic information from the event that triggered the notification.
For example, the following notification definition uses a Go Template to include the name and health status of the check in the notification title:
notification-templateapiVersion: mission-control.flanksource.com/v1
kind: Notification
spec:
events:
- check.failed
- check.passed
title: Check {{.check.name}} is {{.check.health}}
In this example {{.check.name}}
and {{.check.health}}
are placeholders that will be replaced with the actual values of the name
and health
fields from the check object associated with the event.
All notification templates in Mission Control are defined in markdown, and depending on the support of the notification channel it will either be converted to HTML or plain text.
Filtering Events
Mission Control allows you to fine-tune your notification delivery by filtering events using CEL. This enables you to specify precise conditions that dictate when a notification should be triggered. For instance, you can configure notifications to be sent only for specific event types, specific resources, or when certain conditions are met.
The CEL filters you define have access to the same set of variables as the templates, providing flexibility in defining your filtering criteria. These variables, representing various attributes and properties of the events, empower you to create highly targeted notifications.
To illustrate, consider a scenario where you want to receive notifications exclusively for failed HTTP checks. The following example demonstrates how to achieve this using a CEL filter:
filter-http.yamlapiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: http-alerts
spec:
events:
- check.failed
# Filter for events where the check type is 'http'
filter: check.type == 'http'
to:
email: alerts@acme.com
In this example:
- The
filter
field specifies the CEL expressioncheck.type == 'http'
. - This expression evaluates to true only when the
type
attribute of the check object is equal to'http'
. - Consequently, notifications will be sent only for events that satisfy this condition, ensuring that you are alerted specifically for failed HTTP checks.