Ingesting Cloudflare Logs and Metrics into Statsig
Run Statsig server SDK evaluations inside Cloudflare Workers, including configuration, request lifecycle, and how to log exposures from the edge.
How Cloudflare Logpush integration works
This guide walks you through setting up the Cloudflare Logpush worker in your Cloudflare account and configuring it to send logs and metrics to Statsig using curl and the Logpush API.
✅ Prerequisites
Configuring Logpush worker
- Create an API token.
- Ensure the token has logs edit permissions at the account level.
- Locate your Cloudflare account ID.
- Run the following command and get the job ID:
plaintext
ACCOUNT_ID=<my account id>
CLOUDFLARE_API_TOKEN=<cloudflare token>
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "statsig-logpush-job",
"destination_conf": "https://api.statsig.com/v1/log_event/cf_log_drain?header_statsig-api-key=<statsig-secret-key>&header_Content-Type=application%2Fjson",
"dataset": "workers_trace_events",
"output_options": {
"field_names": [],
"output_type": "ndjson",
"batch_prefix": "{\"events\":[",
"batch_suffix": "\n]}\n",
"record_prefix": "\n {\"info\":{",
"record_suffix": "}}",
"record_delimiter": ",",
"timestamp_format": "rfc3339"
}
}'
- In the Cloudflare dashboard, navigate to Analytics & Logs > Logpush and enable the logpush job.
Verify logs on Statsig Console
Explore your logs and metrics at console.statsig.com using the Logs Explorer and Metrics Explorer products under Analytics in the sidebar.🔗 Resources
Was this helpful?