PostHog provides product analytics, logs, and error tracking. Export Cloudflare logs to correlate them with sessions and events.
This guide configures PostHog to receive Cloudflare logs.
Before you begin, you need:
- An active PostHog account ↗︎
- Your PostHog project API key
- Cloudflare logs available for export
- Log in to your PostHog account ↗︎.
- Go to Project settings ↗︎.
- Find Project API key in the project details.
- Copy the project API key.
The project API key starts with phc_.
PostHog uses different endpoints for each data region:
| Region | Logs endpoint |
|---|---|
| US (default) | https://us.i.posthog.com/i/v1/logs |
| EU | https://eu.i.posthog.com/i/v1/logs |
Find your region in your PostHog project settings. Your PostHog URL also contains us or eu.
-
In the Cloudflare dashboard, go to Observability > Destinations.
Go to OpenTelemetry ↗ -
Select Add destination.
-
Configure the destination:
- Destination name:
posthog-logs - Destination type: Logs
- OTLP endpoint: Your PostHog regional logs endpoint
- Custom header name:
Authorization - Custom header value:
Bearer <YOUR_PROJECT_API_KEY>
- Destination name:
-
Select Save.
Creating a destination does not start exporting logs. To export Workers Logs, configure OpenTelemetry export for your Worker. PostHog does not support Workers Traces or Cloudflare Traces through OTLP.
- Log in to your PostHog account ↗︎.
- Go to Logs.
- Review exported severity levels, timestamps, and attributes.
You can filter logs by severity, time range, attributes, and keywords.
- Verify that the API key starts with
phc_. - Confirm that the endpoint matches your PostHog region.
- Check the destination status in the Cloudflare dashboard.
- Check whether sampling excludes the expected logs.
Confirm that the Authorization value includes the Bearer prefix. Also verify that the project API key remains active.
Alternatively, add the token to the endpoint query string: https://us.i.posthog.com/i/v1/logs?token=<YOUR_PROJECT_API_KEY>.