<@ULVA73B9P> how do I know why an automation is no...
# ask-marvin
l
@Marvin how do I know why an automation is not triggering? is there a log somewhere?
m
thought for 180.7 seconds
Great question. Short answer: there isn’t a per-automation “why didn’t this trigger?” audit log in the UI today. The way to debug is to look at the event stream and your automation’s config, and (if self-hosted) the server logs that show trigger evaluations. Here’s a quick workflow: 1) Verify the automation is enabled and the config is what you expect
Copy code
prefect automation inspect "<automation-name>" --yaml
# or
prefect automation inspect --id <automation-id> --json
2) Watch the event stream to see what’s actually happening - This is the primary way to tell whether the events your trigger expects are occurring, with the right resource IDs/tags, and within the time window.
Copy code
prefect events stream --format text
# or JSON and save to a file
prefect events stream --format json --output-file events.log
# In Prefect Cloud, include account-wide audit logs:
prefect events stream --account
What to look for: - Do the event names match your trigger’s
expect
? - Do the resource labels/ids/tags match your
match
/
match_related
filters? - Are they arriving within the
within
window and meeting the
threshold
? Also look for automation-specific events: -
prefect.automation.triggered
-
prefect.automation.resolved
-
prefect.automation.action.triggered
/
.executed
/
.failed
3) Check in the UI - Automations page: confirm it’s enabled and review the trigger config. - Events feed: watch for the events you expect to drive the automation. - Flow run detail pages: view the events attached to a specific run to confirm what actually fired. 4) If you’re self‑hosting, enable debug logs to see evaluation decisions - The server’s trigger evaluator logs why a trigger is or isn’t ready (thresholds, time windows, for_each buckets). - Set:
Copy code
PREFECT_LOGGING_LEVEL=DEBUG
Then watch your server logs; you’ll see messages indicating whether an automation met its threshold, still has time remaining in the window, or was not ready to fire. Common gotchas to check: - The automation is paused/disabled. - Event names don’t match
expect
(e.g., expecting Completed vs Succeeded). -
match
/
match_related
filters don’t align with actual `resource.id`/tags on the events. -
within
window too short or
threshold
too high. -
for_each
bucketing on a label that isn’t present on your events, so the trigger is evaluating per empty key. If you can share the automation definition (YAML/JSON) and the event you expected to trigger it, I’m happy to help pinpoint the mismatch.
l
@Marvin is there a way to watch for a automation? I tried all the other things you mentined
m
thought for 140.7 seconds
Yes—while there isn’t a built-in “watch” command for a single automation, you can watch just that automation’s events by filtering the event stream. There’s no
prefect automation watch
command, so use
prefect events stream
and filter by the automation’s resource id (
prefect.automation.<automation-id>
) or name. Quick steps: 1) Get the automation id
Copy code
prefect automation inspect "<automation-name>" --json | jq -r .id
2) Watch all events for that automation (triggered/resolved/actions)
Copy code
AUTOMATION_ID=<paste-id>
prefect events stream --format json | jq --arg id "prefect.automation.$AUTOMATION_ID" 'select(.resource.id == $id)'
3) Only watch when it triggers/resolves
Copy code
AUTOMATION_ID=<paste-id>
prefect events stream --format json | jq --arg id "prefect.automation.$AUTOMATION_ID" 'select(.resource.id == $id and (.event=="prefect.automation.triggered" or .event=="prefect.automation.resolved"))'
4) Only watch action lifecycle for that automation
Copy code
AUTOMATION_ID=<paste-id>
prefect events stream --format json | jq --arg id "prefect.automation.$AUTOMATION_ID" 'select(.resource.id == $id and (.event=="prefect.automation.action.triggered" or .event=="prefect.automation.action.executed" or .event=="prefect.automation.action.failed"))'
Alternatively, filter by name:
Copy code
prefect events stream --format json | jq --arg name "My Automation" 'select(.resource.name == $name)'
Programmatic watch (Python)
Copy code
import anyio
from prefect.events.clients import get_events_subscriber
from prefect.events.filters import EventFilter, EventResourceFilter, EventNameFilter

automation_id = "<your-automation-id>"

filt = EventFilter(
    resource=EventResourceFilter(id=[f"prefect.automation.{automation_id}"]),
    event=EventNameFilter(name=[
        "prefect.automation.triggered",
        "prefect.automation.resolved",
        "prefect.automation.action.triggered",
        "prefect.automation.action.executed",
        "prefect.automation.action.failed",
    ])
)

async def main():
    async with get_events_subscriber(filter=filt) as sub:
        async for ev in sub:
            print(ev.event, ev.occurred, ev.resource.name)

anyio.run(main)
If you share the automation name, I can give you a copy/paste command that targets it directly.