Hi everyone, I've set up a new automation that not...
# prefect-cloud
j
Hi everyone, I've set up a new automation that notifies us when a flow that has entered the run state but hasn't completed in a predefined window. It's a compound trigger and I have six child triggers configured to fire depending on a set of tags and time periods (i.e. flows with tags "daily") will fire if it hasn't entered
prefect.flow-run.Completed
in 30 hours). I'm trying to set up an action so that it sends a slack notification with the triggered deployment name, but the properties i define in the message body using jinja don't return anything. Any idea how to fix this?
JSON used to define the automation:
Copy code
{
  "type": "compound",
  "triggers": [
    {
      "type": "event",
      "match": {
        "prefect.resource.id": "prefect.flow-run.*"
      },
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.fifteen-minutes"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 10
    },
    {
      "type": "event",
      "match": {},
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.daily"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 108000
    },
    {
      "type": "event",
      "match": {},
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.hourly"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 10800
    },
    {
      "type": "event",
      "match": {},
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.six-hours"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 32400
    },
    {
      "type": "event",
      "match": {},
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.minute"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 600
    },
    {
      "type": "event",
      "match": {},
      "match_related": {
        "prefect.resource.id": [
          "prefect.tag.weekly"
        ],
        "prefect.resource.role": "tag"
      },
      "after": [
        "prefect.flow-run.Running"
      ],
      "expect": [
        "prefect.flow-run.Completed"
      ],
      "for_each": [
        "prefect.resource.id"
      ],
      "posture": "Proactive",
      "threshold": 1,
      "within": 756000
    }
  ],
  "require": "any",
  "within": 0
}
n
hi @Jean Paul Azzopardi! we can use jinja templating here to render
parameters
from the triggering event
Copy code
{
  "name": "My Automation Name",
  "trigger": { ... that whole compound trigger ... },
  "actions": [
    {
      "type": "run-deployment",
      "source": "selected",
      "deployment_id": "...the uuid of the deployment..."
      "parameters": {"some_kwarg": "{{ event.resource.id }}"} # other labels here under resource
    }
  ]
}
sorry, i had posted something a bit incorrect at first
also, I think you may want
within: null
(or omit that key) for the outermost (compound) trigger since I'm not sure what
within: 0
would actually mean
j
Thanks @Nate - I tried amending the JSON to add your suggested changes but every time I save the Automation, it reverts back to the original JSON without the changes. Any idea why this might be happening?
n
I'd imagine that we have some default template in the UI that is taking over when you switch the form view to the JSON view if its not translating the two right, would you be open to creating an issue labeled with
ui
?