Mehdi Lallouache
10/20/2025, 8:05 AMMarvin
10/20/2025, 8:05 AMMarvin
10/20/2025, 8:12 AMprefect automation --help).
- Use the UI for setup, or the REST API if you need to create them programmatically.
Option B — Emit a custom event when a deployment becomes Not Ready, then automate
If you’d like a deployment-specific alert, run a tiny monitoring flow on an interval that checks the deployment’s status and emits an event when it’s NOT_READY. Then create an Automation with an Event Trigger that matches your custom event and sends a notification.
Example flow (minimal) that checks a deployment and emits an event:
import os
import httpx
from prefect import flow
from prefect.events.utilities import emit_event
API_URL = os.environ["PREFECT_API_URL"]
API_KEY = os.environ["PREFECT_API_KEY"]
def get_deployment_status(deployment_id: str) -> str:
r = httpx.get(
f"{API_URL}/deployments/{deployment_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=10.0,
)
r.raise_for_status()
return r.json()["status"] # "READY" or "NOT_READY"
@flow
def check_deployment_readiness(deployment_id: str, deployment_name: str):
status = get_deployment_status(deployment_id)
if status != "READY":
emit_event(
event="deployment.readiness.not_ready",
resource={
"prefect.resource.id": f"prefect.deployment.{deployment_id}",
"prefect.name": deployment_name,
},
payload={"status": status},
)
Then:
- Create an Automation with an Event Trigger
- expect: deployment.readiness.not_ready
- match resource: prefect.deployment.<your-id>
- action: Send Notification (Slack/Teams/email via a configured notification block)
- Reference: Creating automations, Event triggers, and the event utility used above: Events conceptMarvin
10/20/2025, 8:12 AMMehdi Lallouache
10/20/2025, 8:14 AMMarvin
10/20/2025, 8:14 AMMarvin
10/20/2025, 8:17 AM