<@ULVA73B9P> How to use an automation to match on ...
# ask-marvin
j
@Marvin How to use an automation to match on "all flow runs EXCEPT x, y, z" logic?
m
thought for 357.9 seconds
Yes—use negation in your automation’s match filters. In Prefect 3.x, you can exclude specific flows by name with the
!
prefix (and you can use a trailing wildcard like
!prefix-*
). Quick example (edit your automation trigger in the UI’s JSON/YAML editor): JSON (UI “Edit as JSON”)
Copy code
{
  "type": "event",
  "posture": "Reactive",
  "expect": [
    "prefect.flow-run.Failed"
  ],
  "match": {
    "prefect.resource.id": "prefect.flow-run.*",
    "prefect.resource.name": [
      "!x",
      "!y",
      "!z"
    ]
  },
  "threshold": 1
}
YAML (be sure to quote values that start with “!”)
Copy code
trigger:
  type: event
  posture: Reactive
  expect:
    - prefect.flow-run.Failed
  match:
    prefect.resource.id: "prefect.flow-run.*"
    prefect.resource.name:
      - "!x"
      - "!y"
      - "!z"
  threshold: 1
Notes and tips - You can exclude by prefix:
"!debug-*"
(only trailing
*
is supported). - Values are case-sensitive. - Within a single label, lists are OR’ed; across labels, conditions are AND’ed. - If you’re writing YAML, always quote
!something
to avoid YAML interpreting it as a directive. - The Prefect CLI currently supports listing/inspecting/pausing/resuming/deleting automations, but not creating them—create/edit via the UI or API. Docs - Automations overview: Automations - Event triggers and matching: Event triggers and matching