Skip to main content

Event Triggers

Playbook events are triggers that cause a Playbook to run. Events are triggered when specific activity on Mission Control occurs. For example: you can trigger a Playbook to run when a component goes unhealthy.

Multiple playbooks could be listening to the same event and likewise a playbook can be listening to multiple events. If a playbook is listening on multiple events then it is triggered when any of those events occur.

Filters can give you fine-grained control over the events that can trigger the playbook.

FieldDescriptionScheme
event*

Event to listen for

Event

filter

CEL

labels

Labels specifies the key-value pairs that the associated event's resource must match.

[map[string]string]

Types​

Canary events​

Canary events relate to activities on health checks.

EventDescription
passedWhen a previously failed check passes
failedWhen a previously passed check fails

Example​

notify-passing-http-checks.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: notify-passing-http-checks
spec:
description: Notify when any HTTP check passes
on:
canary:
- event: passed
filter: check.type == 'http'
actions:
- name: Send notification
notification:
connection: connection://telegram/playbook-alerts
title: 'Check {{.check.name}} has passed'
message: 'Description: {{.check.description}}'

Component events​

Component events relate to changes in component health status.

EventDescription
healthyWhen a component becomes healthy
unhealthyWhen a component becomes unhealthy
warningWhen a component enters a warning state
unknownWhen a component's health is unknown

Example​

notify-unhealthy-database-component.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: notify-unhealthy-database-component
spec:
description: Notify when a database component goes unhealthy
on:
component:
- event: unhealthy
filter: component.type == 'database'
labels:
env: production
actions:
- name: Send notification
notification:
connection: connection://telegram/playbook-alerts
title: 'Database {{.component.name}} has become unhealthy'
message: 'Description: {{.component.description}}'

Config events​

Config events relate to activities on config items.

EventDescription
createdWhen a config item is created
updatedWhen a config item is updated
changedWhen a config change is recorded
deletedWhen a config item is deleted
healthyWhen a config item becomes healthy
unhealthyWhen a config item becomes unhealthy
degradedWhen a config item becomes degraded
warningWhen a config item enters a warning state
unknownWhen a config item's health becomes unknown

Example​

notify-newly-scraped-pod.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: notify-on-pod-config-creation
spec:
description: Notify when a new pod is discovered
on:
config:
- event: created
filter: config.config_class == 'Pod'
actions:
- name: Send notification
notification:
connection: connection://telegram/playbook-alerts
title: 'A new kubernetes pod {{.config.name}} was scraped'
message: 'Namespace: {{.config.tags.namespace}}'

Schedule​

A playbook can also run on a recurring cron schedule, without any triggering resource.

FieldDescriptionSchemeRequired
scheduleCron expression, e.g. 0 9 * * MON or @every 1hstringtrue
parametersParameters passed to each run. Supports template expressions evaluated at run timemap[string]stringfalse

Schedules are evaluated in UTC by default. Use the CRON_TZ prefix to run in another timezone.

Example​

daily-cost-report.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: daily-cost-report
spec:
description: Email a cost report every weekday morning
on:
schedule:
- schedule: 'CRON_TZ=America/New_York 0 9 * * MON-FRI'
parameters:
since: 24h
actions:
- name: Send report
notification:
connection: connection://smtp/default
title: 'Daily cost report'
message: 'Costs for the last {{.params.since}}'