Kyle McChesney
06/16/2026, 9:55 PMMarvin
06/16/2026, 9:55 PMMarvin
06/16/2026, 9:57 PMcall-webhook automation action and transform event payloads into PutMetricData
2. Event-triggered flow → boto3 CloudWatch
- Good if you want Prefect to own the transformation logic
3. Custom event subscriber service
- Best if you truly mean all events continuously
- Subscribe to Prefect events and forward them to CloudWatch yourself
Relevant Prefect docs
- Events API/catalog: Prefect events reference
- Automations: Automations concepts
- Event triggers: Event triggers
- Webhooks: Webhooks concepts
- Create a webhook: Create a webhook
- Pass event payloads to flows: Passing event payloads to flows
- Custom notifications / templating examples: Custom notifications
A practical caveat
If you literally want all Prefect events as CloudWatch metrics, be careful:
- CloudWatch custom metrics can get expensive
- high-cardinality dimensions like flow run IDs / task run IDs are usually a bad idea
- better to aggregate to dimensions like deployment, flow, work_pool, state, event
So usually you’d map:
- prefect.flow-run.Completed → metric FlowRunCompleted
- prefect.flow-run.Failed → metric FlowRunFailed
- prefect.task-run.Failed → metric TaskRunFailed
Example architecture
text
Prefect Events
-> Automation trigger
-> call-webhook
-> API Gateway / Lambda
-> CloudWatch PutMetricData
If you want true “all events” streaming
A custom subscriber is likely the better fit than many automations.
Very rough sketch:
python
from prefect.events import get_events_subscriber
import boto3
cloudwatch = boto3.client("cloudwatch")
async def forward_events():
async with get_events_subscriber() as subscriber:
async for event in subscriber:
cloudwatch.put_metric_data(
Namespace="Prefect",
MetricData=[
{
"MetricName": event.event,
"Value": 1,
"Unit": "Count",
}
],
)
That said, I’d normalize metric names before sending them.
What I did not find
- No official Prefect doc specifically for CloudWatch Metrics export
- No obvious built-in “export all events to AWS CloudWatch” feature
- No matching GitHub discussion surfaced for this exact pattern
If you want, I can give you either:
1. a full Lambda example for call-webhook → CloudWatch, or
2. a full subscriber service example for forwarding all events.