<@ULVA73B9P> I want to only notify through automat...
# ask-marvin
j
@Marvin I want to only notify through automations if a run fails and is not succesfully run again in the subsequent 3 hours. How do i do this?
m
thought for 674.7 seconds
Great goal—this is a perfect fit for a “wait-for-recovery” automation in Prefect 3. High-level approach - Create an automation that reacts to a flow-run failure, then “waits” up to 3 hours for a successful run. - If a success does not occur in that window, send the notification. - This is done with a Sequence trigger where the second step uses a proactive posture (i.e., it fires if the expected success event does not occur within the window). How to set it up in the UI (Prefect Cloud) 1) Go to Automations → New automation. 2) Trigger builder: - Add a Sequence trigger. - Step 1: - Event: Flow run failed (event name is
prefect.flow-run.FAILED
) - Scope: choose what to watch (e.g., a specific deployment, a flow, or tags). - For each: set to deployment if you want one “recovery window” per deployment. This ensures multiple failures on different deployments don’t interfere with each other. - Step 2: - Event: Flow run completed (event name
prefect.flow-run.COMPLETED
) - Posture: Proactive (meaning: “alert if this event does not happen”) - Within: 3 hours - Correlation: same deployment as Step 1 (so any successful run of the same deployment counts as a recovery). If you instead want to require the exact same flow run to later complete, correlate by the same flow run — but note most users prefer “same deployment” to allow a new run to qualify as recovery. 3) Action: - Add Send notification - Select your notification block (Slack/Email/etc.), and customize the message. 4) Save and enable the automation. Notes and clarifications - Correlation choice matters: - Same deployment: silences the alert if any run of that deployment completes within 3 hours after a failure (common “recovered” pattern). - Same flow run: would only silence if the exact run later completes (less common). - CLI: Prefect 3’s CLI does not support creating automations (you can list/inspect/enable/disable). Use the UI for creation. - Docs: - Event/automation concepts and trigger composition: https://docs-3.prefect.io/v3/concepts/event-triggers Questions for you (so I can tailor this precisely) - Should “recovery” mean the exact same flow run eventually completes, or any subsequent run of the same deployment completes? - Do you want this automation scoped to a specific deployment/flow, or across all deployments?