<@ULVA73B9P> I created two automation, both are ju...
# ask-marvin
j
@Marvin I created two automation, both are just triggering a flow when the previous one enter the completed state. first automation is working perfectly, the other one just do nothing without any error. How can I debug this ?
m
thought for 392.7 seconds
Got it — let’s debug why the second automation isn’t firing. Assuming Prefect 3.x and Cloud. Quick triage checklist - Is it enabled? On the Automation detail page, ensure the toggle is ON. - Did the upstream flow actually emit Completed? Check the upstream run’s status and the Events feed for a
prefect.flow-run.Completed
event. - Does the trigger actually match the upstream event? - Event name/pattern: includes
prefect.flow-run.Completed
- Resource matching: avoid matching by flow-run name; prefer Related resource → role “deployment” (or “flow”) that produced the upstream run. Tag filters must match exactly. - Threshold/posture: Reactive, threshold=1, no “within” required. - Did the automation fire? Look for
prefect.automation.triggered
in Events. If you see it, the trigger fired and the issue is in the action. If you don’t, the trigger didn’t match or wasn’t evaluated. - Is the action configured correctly? - Run deployment: choose “Selected deployment” and pick your downstream deployment. Avoid “Inferred”. - Parameters/templates: try a trivial action (e.g., “Do nothing” or a notification) to confirm the trigger fires; then re-add run-deployment. How to pinpoint the break - In the Events UI: filter for your upstream run and look for: 1)
prefect.flow-run.Completed
(from the upstream run) 2)
prefect.automation.triggered
(for your second automation) 3)
prefect.automation.action.triggered
and then
...action.executed
(for the action’s result) - If 1 exists but 2 does not: the trigger didn’t match (filters/event name/threshold). - If 2 exists but no action events: the action isn’t configured or failed silently; re-check the action target and parameters. API examples (optional, to trace the chain) Replace placeholders with your values; run with a Prefect API key in env.
Copy code
# 1) Confirm the upstream flow-run completed event was recorded
curl -s -X POST <https://api.prefect.cloud/api/events/filter> \
  -H "Authorization: Bearer $PREFECT_API_KEY" \
  -d '{
    "filter": {
      "events": {"filter": "prefect.flow-run.Completed"},
      "resource": {"filter": "prefect.flow-run."}
    },
    "limit": 50
  }' | jq '.events | length'

# 2) Check if your automation fired
# Find events for your automation by automation id (prefect.automation.<automation_id>)
curl -s -X POST <https://api.prefect.cloud/api/events/filter> \
  -H "Authorization: Bearer $PREFECT_API_KEY" \
  -d "{
    \"filter\": {
      \"events\": {\"filter\": \"prefect.automation.triggered\"},
      \"resource\": {\"filter\": \"prefect.automation.<YOUR_AUTOMATION_ID>\"}
    },
    \"limit\": 20
  }" | jq '.events[] | {id, occurred, event, resource: .resource."prefect.resource.id"}'

# 3) If it fired, check the action events
curl -s -X POST <https://api.prefect.cloud/api/events/filter> \
  -H "Authorization: Bearer $PREFECT_API_KEY" \
  -d "{
    \"filter\": {
      \"events\": {\"filter\": \"prefect.automation.action.*\"},
      \"resource\": {\"filter\": \"prefect.automation.<YOUR_AUTOMATION_ID>\"}
    },
    \"limit\": 50
  }" | jq '.events[] | {event, occurred, payload}'
Common gotchas - Matching the wrong resource:
prefect.flow-run.Completed
events are for flow-runs. If you match by resource name (often the flow-run name) or by deployment name in the main filter, it won’t match. Use “Related resource” → role “deployment” or “flow” with the correct item, or a reliable tag. - Tag mismatches: if your trigger uses tags, ensure the upstream run actually has them. - Proactive posture/threshold: if set, the trigger may wait for absence of events or multiple events before firing. - “Inferred” run-deployment action: can be ambiguous and sometimes blocked; use “Selected deployment”. Helpful docs - Automations overview: Automations concept - Event triggers (matching, posture, thresholds): Event triggers
- Events and resource/related matching: Events concept - Chaining deployments with events: Chaining deployments how-to - Events API (query): Read events API If you can share: - A screenshot or JSON of the second automation’s trigger (event, resource/related filters) and action config - The upstream flow run ID and when it completed - Whether you’re on Cloud or self-hosted …I can spot-check the configuration and tell you exactly where it’s getting stuck.
j
@Marvin Here is the json of the trigger for my second automation : ```json { "type": "event", "match": { "prefect.resource.id": "prefect.flow-run.*" }, "match_related": { "prefect.resource.id": [ "prefect.tag.notify-on-failure" ], "prefect.resource.role": "tag" }, "after": [], "expect": [ "prefect.flow-run.Crashed", "prefect.flow-run.TimedOut", "prefect.flow-run.Failed" ], "for_each": [ "prefect.resource.id" ], "posture": "Reactive", "threshold": 1, "within": 0 }
m
thought for 147.9 seconds
Thanks for sharing the trigger JSON — that helps a lot. Key observations about your trigger - It only fires on failures:
expect
includes Crashed/TimedOut/Failed. It will not fire on Completed. If your intent is to chain on completion, you’ll need to add
prefect.flow-run.Completed
(see example below). - It requires a specific tag:
match_related
requires the event to have a related resource with role
tag
and id
prefect.tag.notify-on-failure
. If your upstream flow run (or its deployment/flow) does not actually carry that tag, the trigger will never match. How to confirm where it’s stuck 1) Check if your upstream run produced a matching event - In the Events UI, filter for the upstream flow run and look for: - For failures:
prefect.flow-run.Failed
(or Crashed/TimedOut) - For completions:
prefect.flow-run.Completed
2) Check if the automation fired - Search for
prefect.automation.triggered
scoped to your automation. If you don’t see this, the trigger didn’t match (filters/tags/event name/threshold). 3) Verify the tag filter actually matches - Open a known upstream flow-run event and inspect its “Related” resources. - Do you see a related resource with role
tag
and id exactly
prefect.tag.notify-on-failure
? - If not, that’s the blocker. Either add that tag to the upstream deployment/flow so it appears on the run, or remove/change the tag filter. Quick A/B test to isolate the issue - Temporarily remove the
match_related
block (tag requirement), keep everything else the same, and reproduce the upstream event. - If it fires now, the tag filter was the mismatch. - Alternatively, add
prefect.flow-run.Completed
to
expect
and test a completed run if that’s your intent. Examples A) Trigger on Completed (keeping your tag requirement)
Copy code
{
  "type": "event",
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "match_related": {
    "prefect.resource.id": [
      "prefect.tag.notify-on-failure"
    ],
    "prefect.resource.role": "tag"
  },
  "expect": [
    "prefect.flow-run.Completed"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 1,
  "within": 0
}
B) Trigger on Failed/Crashed/TimedOut but without tag filtering (to test)
Copy code
{
  "type": "event",
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "expect": [
    "prefect.flow-run.Crashed",
    "prefect.flow-run.TimedOut",
    "prefect.flow-run.Failed"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 1,
  "within": 0
}
If you need to scope to a specific upstream deployment instead of a tag, use
match_related
for role `deployment`:
Copy code
"match_related": {
  "prefect.resource.id": ["prefect.deployment.<YOUR_DEPLOYMENT_ID>"],
  "prefect.resource.role": "deployment"
}
Helpful docs - Automations overview: Automations concept - Event matching (expect/match/match_related): Event triggers - Events and related resources: Events concept - Chaining deployments: Chaining deployments how-to If you can confirm: - Whether you want to trigger on Completed or only on failures - A sample upstream flow run ID and whether it actually has the
notify-on-failure
tag - The action you’re using (e.g., Run deployment, selected vs inferred) …I can spot the exact change to make this automation fire.
j
@Marvin I removed all filters on tags or run state, but this automation still doesn't start, like if no event matched
m
thought for 51.2 seconds
Thanks for the update. If you’ve removed both tag filters and run-state filters and it still doesn’t fire, it likely means the trigger isn’t matching the events you think it should, or the automation isn’t enabled/evaluated. Let’s quickly isolate where it’s failing. 1) Verify it’s being evaluated at all - Ensure the automation is enabled (toggle is ON). - In the Automation detail page, open the Activity/Events view and look for
prefect.automation.triggered
. If you see zero entries, the trigger didn’t match any events. 2) Sanity-test with a known-good trigger Create (or temporarily change to) this very permissive trigger to prove evaluation is working. It will fire on any flow-run event:
Copy code
{
  "type": "event",
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "expect": [
    "prefect.flow-run.*"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 1,
  "within": 0
}
- Then run any flow in the same workspace. You should see an
prefect.automation.triggered
event and the action run (use a simple action like “Do nothing” to verify the trigger fires). 3) If it still doesn’t fire, trace the events Use the Events UI or the API to confirm the upstream event exists and whether the automation triggered:
Copy code
# A) Do flow-run events exist?
curl -s -X POST <https://api.prefect.cloud/api/events/filter> \
  -H "Authorization: Bearer $PREFECT_API_KEY" \
  -d '{"filter": {"events": {"filter": "prefect.flow-run.*"}}, "limit": 20}' | jq '.events | length'

# B) Did your automation fire?
curl -s -X POST <https://api.prefect.cloud/api/events/filter> \
  -H "Authorization: Bearer $PREFECT_API_KEY" \
  -d "{
    \"filter\": {
      \"events\": {\"filter\": \"prefect.automation.triggered\"},
      \"resource\": {\"filter\": \"prefect.automation.<YOUR_AUTOMATION_ID>\"}
    },
    \"limit\": 20
  }" | jq '.events[] | {occurred, event, resource: .resource."prefect.resource.id"}'
- If A returns 0, no flow-run events are being recorded (different workspace?). - If A > 0 but B returns 0, the trigger isn’t matching; please share the current trigger JSON. - If B shows triggers but you don’t see downstream effects, the action may be misconfigured or failing; check for
prefect.automation.action.failed
events. 4) Common pitfalls that match your symptoms - Different workspace: your upstream flow runs must be in the same workspace as the automation. - Automation disabled: easy to miss if you cloned/edited an existing one. - Expect/match not actually broadened: if
expect
is empty it matches all events; if
match
is empty it matches all resources; if either still set narrowly, it can block. - Using “Run deployment” with Inferred target: this can be blocked (infinite loop safeguards) or fail; try “Do nothing” or “Selected deployment” just to confirm the trigger itself fires. Helpful docs - Automations overview: Automations concept - Event triggers (expect/match/match_related): Event triggers - Events concept: Events concept - Chaining deployments: Chaining deployments how-to If you can share: - The current trigger JSON (after removing filters) - The automation ID - A specific upstream flow run ID and when it finished - The current action configuration …I’ll pinpoint why it isn’t matching and suggest the exact fix.
j
@Marvin I'm using a self hosted version of prefect, where can I see the : Automation detail page, open the Activity/Events view ?
m
thought for 205.9 seconds
Thanks for clarifying you’re on self-hosted. Short answer: in the current Prefect 3 self-hosted UI, there isn’t an Activity/Events tab on the Automation detail page. You can view and edit automations at: - UI list: http://localhost:4200/automations - Detail page: http://localhost:4200/automations/automation/&lt;automation_id> But to see whether an automation fired (and which events it matched), you’ll need to query the Events API directly. How to check if your automation is firing (self-hosted) - Confirm flow-run events exist at all
Copy code
curl -s -X POST <http://localhost:4200/api/events/filter> \
  -H "Content-Type: application/json" \
  -d '{"filter": {"event": {"prefix": ["prefect.flow-run."]}}, "limit": 20}'
- Check if your automation fired
Copy code
curl -s -X POST <http://localhost:4200/api/events/filter> \
  -H "Content-Type: application/json" \
  -d "{
    \"filter\": {
      \"event\": {\"name\": [\"prefect.automation.triggered\", \"prefect.automation.resolved\"]},
      \"resource\": {\"id\": [\"prefect.automation.<YOUR_AUTOMATION_ID>\"] }
    },
    \"limit\": 50
  }"
- Very permissive trigger to sanity-check evaluation Set your automation trigger to:
Copy code
{
  "type": "event",
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "expect": [
    "prefect.flow-run.*"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 1,
  "within": 0
}
Then run any flow in the same workspace; re-check the
prefect.automation.triggered
events via the API. Other things to confirm - Automation is enabled on the detail page. - You’re testing in the same workspace as the automation. - Temporarily set the action to “Do nothing” to isolate trigger evaluation from action execution. - If using run-deployment, use “Selected deployment” rather than “Inferred”. Docs for reference - Automations: Automations concept - Event triggers: Event triggers - Events API (query): Read events API If you can share your current trigger JSON (after removing filters), your automation ID, and one flow run ID you expect to match, I can help you craft the exact filter to verify whether it should match and why it isn’t.