Totally fine to do it in the UI. Here’s the shortest path that works today, including your Slack alert.
Because your channel dropdown is empty, use a Slack Webhook block in the action (the webhook already targets a channel so you don’t need the dropdown).
Step-by-step in Prefect Cloud UI
- Create a Slack Webhook block (if you don’t have one)
- Blocks → Add block → Notifications → Slack Webhook
- Paste your Incoming Webhook URL (from Slack) and save it (e.g., alerts/slack)
- Docs:
https://docs-3.prefect.io/integrations/prefect-slack/
- Get the exact “cancelled” event name (one-time)
- In a terminal: prefect events stream --format text
- Cancel one flow run; copy the event name printed for that cancellation
- Create the Automation
- Automations → New Automation
- Name it and keep Posture = Reactive
- Trigger
- Click into the “Custom JSON” (advanced) editor
- Paste one of the JSON templates below (choose A or B)
- Replace YOUR_CANCELLATION_EVENT_NAME with what you observed
- Replace YOUR_FLOW_NAME with the flow you’re monitoring
- Action
- Send notification
- Choose the Slack Webhook block you created (e.g., alerts/slack)
- Set your message (e.g., “Flow YOUR_FLOW_NAME cancelled 5 times in 10 minutes.”)
- Save and enable
Custom trigger JSON options
A) Frequent cancellations (N in a time window — robust and recommended)
This fires when there are 5 cancellations within 10 minutes. It’s not “strictly consecutive,” but it’s the most reliable detection in practice.
{
"type": "composite",
"within": "10m",
"expect": 5,
"triggers": [
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{
"resource": {
"prefect.resource.type": "prefect.flow",
"prefect.resource.name": "YOUR_FLOW_NAME"
}
}
]
}
}
]
}
B) “Several in a row” (sequence — best-effort)
Models five cancellations in sequence within 10 minutes. Note: Sequence checks ordered occurrences; it may not strictly “reset” on other events between them in all cases.
{
"type": "sequence",
"within": "10m",
"triggers": [
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{ "resource": { "prefect.resource.type": "prefect.flow", "prefect.resource.name": "YOUR_FLOW_NAME" } }
]
}
},
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{ "resource": { "prefect.resource.type": "prefect.flow", "prefect.resource.name": "YOUR_FLOW_NAME" } }
]
}
},
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{ "resource": { "prefect.resource.type": "prefect.flow", "prefect.resource.name": "YOUR_FLOW_NAME" } }
]
}
},
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{ "resource": { "prefect.resource.type": "prefect.flow", "prefect.resource.name": "YOUR_FLOW_NAME" } }
]
}
},
{
"type": "event",
"match": {
"event": ["YOUR_CANCELLATION_EVENT_NAME"],
"related": [
{ "resource": { "prefect.resource.type": "prefect.flow", "prefect.resource.name": "YOUR_FLOW_NAME" } }
]
}
}
]
}
Docs for the curious
- Event triggers:
https://docs-3.prefect.io/v3/concepts/event-triggers
- Slack via Webhook blocks:
https://docs-3.prefect.io/integrations/prefect-slack/
If you give me:
- the flow name (or ID),
- the exact event name you saw for cancellations,
- the count and window you want,
- and the name of your Slack block,
I’ll return a ready-to-paste JSON tailored to you. I’d say I’m excited, but you’d see right through me.