<@ULVA73B9P> Is it possible to export audit logs o...
# ask-marvin
a
@Marvin Is it possible to export audit logs or enable them to be connected to an automation so that we can stream them out to Datadog?
m
thought for 72.8 seconds
Short answer: yes—via events + automations. There isn’t a one-click “export audit log” stream, but you can trigger an Automation on audit-style events and send them to Datadog over HTTP. How it works - Prefect Cloud emits events for most changes (including security/audit-ish things like user, tokens, roles, etc.). - Create an Automation with an Event trigger filtered to the event types you care about. - Add a “Call a webhook” action that POSTs to Datadog’s Logs HTTP intake. Setup steps 1) In Cloud, create an Automation: - Trigger: Event trigger → filter by event types (search for relevant org/user/token/role/automation events). 2) Action: Call a webhook - URL:
<https://http-intake.logs.datadoghq.com/api/v2/logs>
(use the EU site if applicable) - Method: POST - Headers: -
Content-Type: application/json
-
DD-API-KEY: <your-datadog-api-key>
- Body (simple, template-friendly):
Copy code
[
       {
         "ddsource": "prefect",
         "service": "prefect-cloud",
         "message": "{{ event.event }}: {{ event.resource.name or 'n/a' }}",
         "timestamp": "{{ event.occurred }}",
         "attributes": {{ event | tojson }}
       }
     ]
Notes and caveats - This gives you near-real-time streaming. If you need historical bulk export, there isn’t a dedicated “export audit log” API endpoint today; events+automations is the supported path. - Be selective with event filters—org-level events can be noisy. - If you actually meant “runtime flow/task logs,” that’s different; you’d typically ship logs directly from your execution environment to Datadog using a logging handler or agent. Docs - Automations overview: https://docs.prefect.io/latest/automations/ - Events (what you can trigger on): https://docs.prefect.io/latest/automations/events/ - Webhook actions: https://docs.prefect.io/latest/automations/actions/ - Datadog logs HTTP intake: https://docs.datadoghq.com/api/latest/logs/#send-logs Quick sanity check - Are you on Prefect Cloud, and do you want org/audit events (users, tokens, roles) or runtime flow/task logs? I’ll tailor the exact event filters or logging approach accordingly.