<@ULVA73B9P> having trouble with my automation not...
# ask-marvin
j
@Marvin having trouble with my automation not firing - can you help?
m
thought for 528.6 seconds
j
anything @Marvin?
m
thought for 26.4 seconds
Hey! I’m here to help with anything Prefect. What are you working on right now? Examples I can jump into: - Creating a deployment and schedule - Setting up a worker/work pool (Docker, Kubernetes, ECS) - Running flows from source (e.g., GitHub, S3) and configuring storage - Using blocks/secrets and environment variables - Troubleshooting failed runs or deployment issues - Migrating from Prefect 2.x to 3.x If you can share a bit more: - Your Prefect version (2.x or 3.x) - Cloud or self-hosted, and where you’re running things - Infrastructure (Docker/K8s/etc.) - Any error messages or a small code snippet I’ll get you concrete steps or code right away.
j
@Marvin my automation is listening for an event - the event happens and the automation doesnt fire in prefect cloud
m
thought for 291.7 seconds
Absolutely—happy to help. A few quick checks usually find the issue. Here’s a fast troubleshooting checklist for Automations in Prefect 3.x: 1) Verify the automation’s status and recent activity - Make sure it’s enabled (not paused) and not in a cooldown window. - Inspect it:
Copy code
prefect 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:
Copy code
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:
Copy code
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:
Copy code
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:
Copy code
prefect automations inspect "<your-automation-name>" --yaml
- A sample event from:
Copy code
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: Events
Got it — let’s track this down. A few quick checks usually reveal why an automation didn’t fire. Quick verification checklist 1) Confirm the event exists - In Prefect Cloud, open the Event Feed and find the event you expect. Click it and review the Resource labels. - Or watch in real-time:
Copy code
prefect event stream --format text
2) Make sure the automation is enabled
Copy code
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:
Copy code
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 &amp; 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.
j
@Marvin do wilcards * work for custom events?
m
thought for 29.8 seconds
Yes. In Prefect 3.x Automations, wildcards work with custom event names in trigger fields like
expect
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
Copy code
# 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
Copy code
prefect events stream --format text
then adjust your wildcard accordingly. Docs: - Event triggers - Events &amp; structure
j
@Marvin so what might be wrong with this "{ "type": "event", "posture": "Reactive", "match": { "prefect.resource.id": "client.*" }, "matchRelated": {}, "forEach": [], "after": [], "expect": [ "*.upload.completed" ], "threshold": 1, "within": 60 }"
m
thought for 60.2 seconds
Short answer: the leading wildcard in
expect
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:
Copy code
{
  "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:
Copy code
prefect event stream --format text
- Inspect the automation to confirm it’s enabled and see the trigger config:
Copy code
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 &amp; structure