Skip to content

Export to PostHog

Last updated View as MarkdownAgent setup

PostHog provides product analytics, logs, and error tracking. Export Cloudflare logs to correlate them with sessions and events.

PostHog logs view with attributes expanded and a timeline view at the top

This guide configures PostHog to receive Cloudflare logs.

Prerequisites

Before you begin, you need:

1. Get your PostHog project API key

  1. Log in to your PostHog account ↗︎.
  2. Go to Project settings ↗︎.
  3. Find Project API key in the project details.
  4. Copy the project API key.

The project API key starts with phc_.

2. Select your PostHog endpoint

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.

3. Configure a Cloudflare Observability destination

  1. In the Cloudflare dashboard, go to Observability > Destinations.

    Go to OpenTelemetry ↗
  2. Select Add destination.

  3. 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>
  4. Select Save.

Cloudflare destination configuration for PostHog logs with destination name, type selection, OTLP endpoint, and custom headers

4. Enable export

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.

5. View logs in PostHog

  1. Log in to your PostHog account ↗︎.
  2. Go to Logs.
  3. Review exported severity levels, timestamps, and attributes.

You can filter logs by severity, time range, attributes, and keywords.

Troubleshooting

Logs do not appear in PostHog

  1. Verify that the API key starts with phc_.
  2. Confirm that the endpoint matches your PostHog region.
  3. Check the destination status in the Cloudflare dashboard.
  4. Check whether sampling excludes the expected logs.

Fix authentication errors

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>.

Was this helpful?