Steven Trimboli
08/12/2024, 5:30 PMChris Guidry
08/13/2024, 2:01 PMposture: Proactive
trigger that sends a notification if it hasn't observed a prefect.flow-run.Completed
event from the load-shift-assignments
flow. How you'd match that flow depends on your setup and how you've got things organized, but the fundamental trigger is:
{
"posture": "Proactive",
"match_related": {
"prefect.resource.name": "load-shift-assignments",
"prefect.resource.role": "flow"
},
"expect": "prefect.flow-run.Completed",
"threshold": 1,
"within": 600
}
Breaking that down:
posture: "Proactive"
says "trigger when an event doesn't happen"
match_related: {...}
is saying "match any events that have a related resource named "load-shift-assignments" in the role "flow" (you can take a look at your event feed to see the events for these flow runs, you might want to pick a deployment or work pool instead)
"expect": ["prefect.flow-run.Completed"]
says "i'm expecting a flow run Completed event"
"threshold": 1
says "I'm expecting one event"
"within": 600
says "I'm expecting an event every 600 seconds" (you may want to pad this a bit to account for late start times, etc)
Taking that all together, the trigger fires when it hasn't seen 1 "prefect.flow-run.Completed" event for the "load-shift-assignments" flow within the last 10 minutes. The trigger can fire at most once every 10 minutes, then resets until the next windowSteven Trimboli
08/13/2024, 2:21 PMSteven Trimboli
08/13/2024, 2:22 PMChris Guidry
08/13/2024, 2:25 PM"match_related": {
"prefect.resource.id": "prefect.tag.my-tag-name",
"prefect.resource.role": "tag"
}
Chris Guidry
08/13/2024, 2:29 PMmy-tag-name
every 10 minutes".
If you want to break that out so you can get separate alerts for each flow that misses its window, it would look something like this:
"match_related": {
"prefect.resource.id": "prefect.tag.my-tag-name",
"prefect.resource.role": "tag"
},
"for_each": ["related:flow:prefect.resource.id"]
That for_each
syntax is a little obscure, but the idea is that for_each
will establish separate event counters for each combination of event labels you give it. The related:flow:
prefix is saying "keep track of a different count for a label in a related flow", so this will keep track of a separate count for each flow (based on its ID). You could use "related:deployment:prefect.resource.id"
if you wanted to keep track of separate counters by deployment.Chris Guidry
08/13/2024, 2:31 PMSteven Trimboli
08/13/2024, 2:51 PMKG
08/15/2024, 7:08 PMZach Angell