Skip to main content

Ingesting Cloudflare Logs into Statsig

Overview

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

  1. Create api token
  2. Make sure token has logs edit permissions at the account level
  3. Locate cloudflare account ID
  4. Run the following command and get the job id
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 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 with the Logs Explorer and Metrics Explorer products under Analytics on the sidebar menu 🙂


🔗 Resources