Generally, events have a consistent and informative grammar - an event describes a resource and an action that the resource took or that was taken on that resource. For example, events emitted by Prefect objects take the form of:
Events are automatically emitted by all Prefect objects, including flows, tasks, deployments, work queues, and logs. Prefect-emitted events will contain the prefect or prefect-cloud resource prefix. Events can also be sent to the Prefect events API via authenticated http request.
The Prefect Python SDK provides an emit_event function that emits an Prefect event when called. The function can be called inside or outside of a task or flow. Running the following code will emit an event to Prefect Cloud, which will validate and ingest the event data.
Note that the emit_event arguments shown above are required: event represents the name of the event and resource={"prefect.resource.id": "my_string"} is the resource id.
To get data into an event for use in an automation action, you can specify a dictionary of values for the payload parameter.
Events emitted from any source will appear in the event feed, where you can visualize activity in context and configure automations to react to the presence or absence of it in the future.
Every event has a primary resource, which describes the object that emitted an event. Resources are used as quasi-stable identifiers for sources of events, and are constructed as dot-delimited strings, for example:
Events can optionally contain related resources, used to associate the event with other resources, such as in the case that the primary resource acted on or with another resource:
Prefect Cloud provides an interactive dashboard to analyze and take action on events that occurred in your workspace on the event feed page.
The event feed is the primary place to view, search, and filter events to understand activity across your stack. Each entry displays data on the resource, related resource, and event that took place.
You can view more information about an event by clicking into it, where you can view the full details of an event's resource, related resources, and its payload.
From an event page, you can configure an automation to trigger on the observation of matching events or a lack of matching events by clicking the automate button in the overflow menu:
The default trigger configuration will fire every time it sees an event with a matching resource identifier. Advanced configuration is possible via custom triggers.