> ## Documentation Index
> Fetch the complete documentation index at: https://statsig-4b2ff144-serverless-cloudflare.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingesting Cloudflare Logs and Metrics 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

* [Cloudflare Logpush enabled for your account](https://developers.cloudflare.com/logs/logpush/)
* [Statsig Server SDK Key](https://docs.statsig.com/server-core/)

***

## Configuring Logpush Worker

1. [Create api token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/)
2. Make sure token has logs edit permissions at the account level
3. [Locate cloudflare account ID](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/)
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](http://console.statsig.com) with the Logs Explorer and Metrics Explorer products under Analytics on the sidebar menu 🙂

***

## 🔗 Resources

* [Manage Logpush with cURL](https://developers.cloudflare.com/logs/logpush/examples/example-logpush-curl/)
* [Logpush output types](https://developers.cloudflare.com/logs/logpush/logpush-job/log-output-options/#output-types)
* [Create logpush API docs](https://developers.cloudflare.com/api/resources/logpush/subresources/jobs/methods/create/)
