https://prefect.io logo
Title
t

Taylor Babin

05/02/2023, 7:24 PM
Hi I have a quick question when creating custom Automations as mentioned here https://docs.prefect.io/latest/cloud/automations/#triggers for the following custom trigger how do you only trigger for deployments that have a specific tag
{
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "match_related": {
    "prefect.resource.id": "prefect.deployment.70cb25fe-e33d-4f96-b1bc-74aa4e50b761",
    "prefect.resource.role": "deployment"
  },
  "for_each": [
    "prefect.resource.id"
  ],
  "after": [],
  "expect": [
    "prefect.flow-run.Completed"
  ],
  "posture": "Reactive",
  "threshold": 2,
  "within": 10
}
2
and if possible to show not when it's failed but if it's three lates of a deployment thanks 🙂
w

Will Raphaelson

05/02/2023, 7:39 PM
Hi Taylor, do other deployments share these tags? its not supported at this time to configure triggers to match on multiple criteria, i.e that they have a specific deployment and a specific tag, but its on the roadmap. If you give this deployment a tag that will accurately identify the flow runs, you can use the tag on the trigger like so.
{
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "match_related": {
    "prefect.resource.id": [
      "prefect.tag.prod"
    ],
    "prefect.resource.role": "tag"
  },
  "after": [],
  "expect": [
    "prefect.flow-run.Late"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 3,
  "within": 60
}
Snuck the late status in there as well. If you’re ever curious what events you can automate on, check out the event feed.
t

Taylor Babin

05/02/2023, 7:40 PM
i don't need it specified for a specific deployment just for a specified tag if that works
w

Will Raphaelson

05/02/2023, 7:40 PM
Great, then that snippet above or something like it should work!
t

Taylor Babin

05/02/2023, 7:40 PM
perfect thank you. It's a great new feature you guys added so just getting use to the syntax