https://prefect.io logo
Title
a

Andrew

03/13/2023, 8:52 PM
Hey folks, trying to filter automations to trigger only on a certain queue and not others, is there a way to do that via automations (specifically in the Custom trigger type?). Anyone have guidance there?
w

Will Raphaelson

03/13/2023, 10:01 PM
Hey Andrew, for sure. Any reason not to just select it in the dropdown? If you wanted to do it via the json in the custom one, it would be approximately:
{
  "match": {
    "prefect.resource.id": "prefect.work-queue.70cb25fe-e33d-4f96-b1bc-74aa4e50b761"
  },
  "match_related": {},
  "for_each": [
    "prefect.resource.id"
  ],
  "after": [
    "prefect.work-queue.unhealthy"
  ],
  "expect": [
    "prefect.work-queue.healthy"
  ],
  "posture": "Proactive",
  "threshold": 0,
  "within": 1800
}
More docs on the trigger API here.
screenshot of selecting it in the ui:
a

Andrew

03/15/2023, 4:43 PM
That field does not show up in our UI.
We ended up adding tags to everything on deploy and targeting those, but I don't know if that worked either - let me check and see if this json custom rule works
w

Will Raphaelson

03/15/2023, 5:18 PM
Sorry to be clear, if you select the work queue health top option, the work queue selection doesn’t show up? Can you send me a screenshot of that please
a

Andrew

03/15/2023, 5:22 PM
Ah I see, you're saying to just alert on queue health instead of individual flow run state.
w

Will Raphaelson

03/15/2023, 5:25 PM
ah and i see what you meant, flow run triggers but only flow runs on a specific work queue. yeah tags are probably your best bet right now, thought we could consider adding a work queue to the related resources of a flow run event and then you could match related on that.
👍 1
a

Andrew

03/15/2023, 5:30 PM
And that's also not available in the custom filters, right?
w

Will Raphaelson

03/15/2023, 5:36 PM
You could put a work queue on the match related field of a custom trigger, but it would never fire, because at this time we dont attach a work queue as a related resource on the flow run state change events. thats a super reasonable use case though, and thanks for surfacing it, so I’ll file an issue for our backlog on that now.
a

Andrew

03/15/2023, 5:39 PM
awesome, thanks
w

Will Raphaelson

03/15/2023, 10:17 PM
Good news, i was wrong. We actually are sending that information. A trigger with a configuration similar to the following will get the job done
{
  "match": {
    "prefect.resource.id": "prefect.flow-run.*"
  },
  "match_related": {
    "prefect.resource.id": [
      "prefect.work-queue.prod"
    ],
    "prefect.resource.role": "work-queue"
  },
  "after": [],
  "expect": [
    "prefect.flow-run.*"
  ],
  "for_each": [
    "prefect.resource.id"
  ],
  "posture": "Reactive",
  "threshold": 1,
  "within": 10
}