John Wessel
10/30/2025, 12:53 AMMarvin
10/30/2025, 12:53 AMJohn Wessel
10/30/2025, 12:58 AMMarvin
10/30/2025, 12:59 AMMarvin
10/30/2025, 12:59 AMJohn Wessel
10/30/2025, 1:01 AMMarvin
10/30/2025, 1:01 AMMarvin
10/30/2025, 1:02 AMprefect automations ls
prefect automations inspect "<your-automation-name>" --yaml
Look for fields like enabled, cooldown_seconds, last_matched, and last_triggered. If last_matched is 0, the trigger isn’t matching any events.
2) Confirm the exact event is being emitted
- Stream events from your workspace and reproduce the scenario:
prefect events stream --format text
Copy the exact event name you see and compare it to your automation’s trigger (event names must match exactly). Also check the event’s resource and related fields—these are what flow/deployment name and tag filters match against. If in doubt, temporarily loosen/remove filters to see if it matches.
3) Double-check trigger filters
- Event name: must be an exact match (best to copy from the event stream).
- Resource filters: confirm you’re filtering on attributes that actually exist on the event (e.g., deployment or flow name, tags). If possible, prefer IDs over names to avoid typos.
- Composite/sequence triggers: make sure all subconditions can match in the expected order/time window.
4) If it’s a Metric trigger
- Confirm the metric/query actually returns results and that the evaluation interval/posture is set as intended.
- If available in your UI, test the query; otherwise try simplifying the query to isolate the issue.
5) Environment and connectivity
- Ensure your flows/workers are pointed at the same workspace and are able to emit events:
prefect config view
Confirm PREFECT_API_URL and (for Cloud) PREFECT_API_KEY are set correctly. If events don’t show in the stream, the automation can’t fire.
6) Action succeeded vs. trigger fired
- Even if the trigger matches, the action can fail (e.g., running a paused deployment, work pool paused, concurrency limits). Check the automation’s detail page “Activity” for errors or use:
prefect automations inspect "<your-automation-name>" --yaml
If you can share a bit more, I can pinpoint it quickly:
- Are you on Prefect Cloud or self-hosted?
- The automation YAML:
prefect automations inspect "<your-automation-name>" --yaml
- A sample event from:
prefect events stream --run-once --format text
- What trigger you configured (event name + any filters) and the action you expect.
Helpful docs:
- Automations overview: Automations
- Events and event stream: EventsMarvin
10/30/2025, 1:06 AMprefect event stream --format text
2) Make sure the automation is enabled
prefect automation ls
prefect automation inspect "<your-automation-name>"
Look for Enabled: True and the exact trigger config.
3) Match filters must align with event labels
- In your trigger, the `match`/`match_related` labels must match the event’s Resource/Related labels exactly (only trailing wildcards like foo-* are supported).
- Common mismatch: custom events missing prefect.resource.id or using wrong label keys.
4) Event name + logic
- `expect`: must include the exact event name(s) (e.g., prefect.flow-run.Failed). If empty, any matching event counts.
- `after`: if present, those prerequisite events must have happened.
- Posture: Reactive fires when events happen; Proactive fires when expected events do not happen.
- Threshold/within: Ensure they’re sensible (e.g., threshold=1, within=0 for a simple reactive trigger).
5) for_each can split evaluations
- If for_each=["prefect.resource.id"], events are counted separately per resource id. This can prevent a threshold from being reached if you expected aggregation.
6) If the trigger fires but action doesn’t run
- Verify the action target exists and is valid (deployment/webhook/notification).
- For webhooks, check for failed webhook events in the Event Feed.
Common pitfalls
- Automation is paused.
- Wrong event name (e.g., listening for Completed but event is actually `Finished`/`Running` etc.).
- Selector mismatch (e.g., you matched prefect.resource.name but the event’s label is different).
- Custom event resource missing the required label:
from prefect.events import emit_event
emit_event(
event="my.custom.event",
resource={"prefect.resource.id": "foo-123"}, # required
payload={"details": "anything"},
)
Helpful docs
- Event triggers (3.x)
- Events & event structure
- Create and test automations
- Webhooks and event templates
If you can share:
- A screenshot or YAML/JSON of your automation trigger (match/expect/after/threshold/within/for_each)
- The raw event object from the Event Feed (Resource/Related labels + event name), with secrets redacted
…I can pinpoint the exact mismatch and give you the one-line fix.John Wessel
10/30/2025, 1:09 AMMarvin
10/30/2025, 1:09 AMMarvin
10/30/2025, 1:09 AMexpect and after.
- Use trailing wildcards for event names, e.g. my.custom.* will match my.custom.eventA, my.custom.eventB, etc.
- For label filters (match / match_related), only trailing wildcards are supported on label values as well (e.g., {"prefect.resource.id": "acme-*”}).
Example
# emit a custom event
from prefect.events import emit_event
emit_event(
event="acme.model.training.completed",
resource={"prefect.resource.id": "acme:training:123"},
payload={"duration": 42}
)
Automation trigger (conceptually)
- expect: ["acme.model.training.*"]
- match: {"prefect.resource.id": "acme:training-*"} # optional
Tip: Verify the exact event name in the Event Feed or via
prefect events stream --format text
then adjust your wildcard accordingly.
Docs:
- Event triggers
- Events & structureJohn Wessel
10/30/2025, 1:09 AMMarvin
10/30/2025, 1:09 AMMarvin
10/30/2025, 1:10 AMexpect is the problem.
Details:
- Event name wildcards only support trailing patterns. *.upload.completed will not match. Use either the exact event or a trailing wildcard like:
- ["client.upload.completed"] (exact), or
- ["client.upload.*"] (prefix match)
- Your label filter looks fine if your custom event sets resource={"prefect.resource.id": "client.…"}. Make sure your custom event actually uses the prefect.resource.id label with a value starting with client. — otherwise the match won’t match.
Quick fix example:
{
"type": "event",
"posture": "Reactive",
"match": { "prefect.resource.id": "client.*" },
"matchRelated": {},
"forEach": [],
"after": [],
"expect": ["client.upload.completed"], // or "client.upload.*"
"threshold": 1,
"within": 60
}
Verify quickly:
- Stream the event and copy the exact name:
prefect event stream --format text
- Inspect the automation to confirm it’s enabled and see the trigger config:
prefect automation inspect "<name>"
If you share the exact event name and the event’s Resource labels from the Event Feed, I can confirm the exact pattern you need.
Docs:
- Event triggers
- Events & structure