Skip to main content

prefect.cli.events

Functions

stream

stream(format: StreamFormat = typer.Option(StreamFormat.json, '--format', help='Output format (json or text)'), output_file: str = typer.Option(None, '--output-file', help='File to write events to'), account: bool = typer.Option(False, '--account', help='Stream events for entire account, including audit logs'), run_once: bool = typer.Option(False, '--run-once', help='Stream only one event'))
Subscribes to the event stream of a workspace, printing each event as it is received. By default, events are printed as JSON, but can be printed as text by passing --format text.

handle_event

handle_event(event: Event, format: StreamFormat, output_file: str) -> None

handle_error

handle_error(exc: Exception) -> None

emit

emit(event: str = typer.Argument(help='The name of the event'), resource: str = typer.Option(None, '--resource', '-r', help="Resource specification as 'key=value' or JSON. Can be used multiple times."), resource_id: str = typer.Option(None, '--resource-id', help='The resource ID (shorthand for --resource prefect.resource.id=<id>)'), related: Optional[str] = typer.Option(None, '--related', help='Related resources as JSON string'), payload: Optional[str] = typer.Option(None, '--payload', '-p', help='Event payload as JSON string'))
Emit a single event to Prefect. Examples:
# Simple event with resource ID
prefect event emit user.logged_in --resource-id user-123

# Event with payload
prefect event emit order.shipped --resource-id order-456 --payload '{"tracking": "ABC123"}'

# Event with full resource specification
prefect event emit customer.subscribed --resource '{"prefect.resource.id": "customer-789", "prefect.resource.name": "ACME Corp"}'

Classes

StreamFormat