Hey folks, trying to filter automations to trigger...
# prefect-community
a
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
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:
Copy code
{
  "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
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
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
Ah I see, you're saying to just alert on queue health instead of individual flow run state.
w
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
And that's also not available in the custom filters, right?
w
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
awesome, thanks
w
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
Copy code
{
  "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
}