# Using Cloudflare Logpush

Cloudflare Logpush is a service provided by Cloudflare that enables you to stream your Cloudflare Worker Trace Event Logs to Baselime.

# Usage

Baselime connects to your Cloudflare account and enables Logpush in a few steps:

# 1. Create an API Token

To get started, you need to create an API token for your Cloudflare account. This token will enable Baselime to access create the Logpush and add metadata to your events once they are ingested into Baselime.

Create a user API token with the following permissions from the Cloudflare Dashboard:

  • Logs - Edit: This permission is required to set up logpush configurations to collect logs from Cloudflare.
  • Account Settings - Read: This permission is needed to list the accounts and add them to Baselime automatically.
  • Worker Scripts - Edit: This permission is needed to list the Workers add them to your Baselime Services and enable LogPush.

Select all the Cloudflare accounts you want to observe in Baselime.

Cloudflare Token Creation
Cloudflare Token Creation

# 2. Connect Your Cloudflare Account to Baselime

Use the API Token you created in the previous step to connect your Cloudflare account to Baselime in the Baselime console.

Step 1: Create a new environment

Add Environment
Add Environment

Step 2: Add the API token you created in the previous step and connect your Cloudflare account.

Add your API Token
Add your API Token

# 3. Enable Logpush on Your Cloudflare Workers

To complete the setup, it's necessary to enable Logpush on your Cloudflare Workers.

Add logpush = true to the top level section of your Workers wrangler.toml file

# Top-level configuration

name = "my-worker"
main = "src/index.js"
compatibility_date = "2022-07-12"

workers_dev = false
logpush = true
route = { pattern = "example.org/*", zone_name = "example.org" }

# 4. Using the Cloudflare Workers Logpush integration

Once you've connected your Cloudflare account to Baselime, all your Workers Trace Events will be available in Baselime. You can search, query or tail your logs from the console and the CLI. You can create alerts from derived metrics from your logs. You can use our dashboard templates to create dashboards based on your Cloudflare events, and modify them at will.

Due to limitations in Cloudflare your duration is inferred from the last log of a request. If a request does not have any requests this duration will be set at 1ms. To resolve this add a log message as the last step of your invocation.