Skip to content

Commit

Permalink
playbooks as notification
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Jan 8, 2025
1 parent e2dbfb6 commit a4b5349
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
31 changes: 31 additions & 0 deletions mission-control/docs/guide/notifications/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,35 @@ In this example:
- The `filter` field specifies the CEL expression `check.type == 'http'`.
- This expression evaluates to true only when the `type` attribute of the [check](/reference/canary-checker/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.

## Triggering Playbooks

Playbooks can be configured as recipients for notifications, allowing you to trigger automated workflows instead of sending notifications to traditional channels like email or Slack.

While playbooks themselves are capable of listening to events - just like notifications - this approach leverages the full capabilities of notifications, including:

- Rate Limitation
- Silences
- Repeat Intervals
- WaitFor


```yaml title="playbook-on-unhealthy-configs.yaml" file=<rootDir>/modules/mission-control/fixtures/notifications/health-playbook.yaml
```

This notification above triggers the playbook `mc/echo-config` whenever a config changes its health to the specified list.

#### Permissions

To enable a notification to execute a playbook, you must configure the necessary permissions as follows:

- **Subject**: notification
- **Resource**: playbook
- **Action**: `playbook:run`


:::caution permission
If the required permissions are not set, the playbook will remain in a `pending playbook run` status indefinitely.
Ensure that permissions are correctly configured to avoid this issue.
:::
15 changes: 12 additions & 3 deletions mission-control/docs/reference/notifications/_notification.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
description: "The duration to delay sending a health-based notification.\n\nAfter this period, the health status is reassessed to confirm it hasn't changed, helping prevent false alarms from transient issues.",
scheme: "duration"
},
{
field: "waitForEvalPeriod",
description: "an additional delay after WaitFor before evaluating Kubernetes config health",
scheme: "duration"
},
{
field: "title",
description: "Channel dependent e.g. subject for email",
Expand All @@ -61,7 +66,7 @@
],
},
{
field: "body",
field: "template",
description: "Channel dependent e.g. email body for email",
scheme: "GoTemplate",
templateEnv: [
Expand All @@ -79,8 +84,12 @@
{"name": "ConfigEvents", "url": "/reference/notifications/template_vars#config-health-env"},
{"name": "ComponentEvents", "url": "/reference/notifications/template_vars#component-health-env"},
],
}

},
{
field: "to.playbook",
description: "specify the `<namespace>/<name>` of the playbook that should be triggered when this notification fires.",
scheme: "string",
},
]}/>

:::info Single Recipient
Expand Down

0 comments on commit a4b5349

Please sign in to comment.