Integration with Cloudflare
This guide provides step-by-step instructions to integrate Cloudflare with OpenObserve.
Overview
The Cloudflare integration enables streaming of HTTP request logs, response codes, security events, and related dimensions from Cloudflare to OpenObserve.
Cloudflare offers two methods to send logs to OpenObserve. The method you choose depends on your Cloudflare plan and setup preferences:
- GraphQL API: Available on the following Cloudflare plans- Free, Pro, Business, and Enterprise. This method pulls logs from Cloudflare at regular intervals using an API script.
- Logpush: Available only on Cloudflare Enterprise plans. This method pushes logs from Cloudflare to OpenObserve in real time using an HTTP endpoint.
This integration can help you monitor performance, identify security issues, and troubleshoot problems by using real-time Cloudflare traffic logs in OpenObserve.
Prerequisites
- A Cloudflare account: Sign up here.
- An OpenObserve account: Sign up here.
-
A Cloudflare API token:
- To use the GraphQL method, create a token with the Read analyticsand logs permission
- To use the Logpush method (Enterprise only), create a token with the Edit Logs permission.
-
GraphQL-specific requirements:
- Tools: Python 3.8 or later, terminal access, and ability to use a virtual environment.
- Traffic Source: A live website, a Cloudflare Worker, or an existing traffic.
Steps to Integrate
Step 1: Retrieve Your OpenObserve Endpoint and Credentials
To stream Cloudflare logs, log in to OpenObserve and follow these steps:
- From the left menu, select Data Sources > Custom > Logs > Curl.
- Extract the following details from the sample curl command:
- Endpoint:
https://api.openobserve.ai/api/<organization_name>/<stream_name>/_json
. Replaceorganization_name
with the organization name shown at the top right corner of the screen. Replace thestream_name
with cloudflare_logs. - Credentials:
The sample includes a string in the format:
your-username@example.com:802gZ3uo4N5S917s6Med
. Here, the username isyour-username@example.com
and the password isFNIN8MWspXZRKRgS
.
Step 2: Generate Cloudflare Logs
To generate real logs for the GraphQL method, you need actual traffic routed through Cloudflare. Choose one of the following approaches:
Option 1: Live website traffic using any Cloudflare plan
- Add a domain, such as example.com, in the Cloudflare dashboard.
- Create a proxied DNS A record that points to your server. The proxy status must show the orange cloud icon.
- Generate traffic by visiting the site, sharing the URL, or allowing users to access it.
- Logs are produced when requests reach Cloudflare’s edge.
Option 2: Cloudflare Worker on Free, Pro, Business, or Enterprise plans
- In the Cloudflare dashboard, go to Workers and Pages, then select Create Worker.
- Assign a name, such as log-generator.
- Use the following code:
log-generator.example-subdomain.workers.dev
.
5. You may optionally add a route under Workers Routes, such as example.com/log/*
.
6. Generate traffic by visiting the Worker URL, linking it on a webpage, or enabling access through a known route.

Option 3: Existing traffic on Business or Enterprise plans
- Use a domain or Cloudflare Worker that is already proxied through Cloudflare.
- If the service already receives external traffic, no additional configuration is required. Logs will begin flowing automatically as requests are processed.
Verify traffic in Cloudflare
- From the Cloudflare dashboard, navigate to Analytics and select the Traffic tab.
- Verify that incoming request data appears. This usually takes only a few minutes.
Step 3: Stream Logs to OpenObserve
There are two options to send logs from Cloudflare to OpenObserve. Click each tab to learn more:
Generate API token:
- In the Cloudflare dashboard, go to My Profile > API Tokens > Create Token.
- Select the Read analytics and logs template. Apply the token to all zones or selected zones.
Note: You can also create a custom token with the following scope: Zone > Analytics > Read.
- Copy the API token. For example,
xUL39zImSqAG5-JJNpLMC7HVIqGuckorb9AKo-Tx
.
Set up environment
- Open a terminal and run the following commands to prepare the Python environment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
(Optional) To run the script continuously in the background, use:
Generate an API Token:
- In the Cloudflare dashboard, go to My Profile and select API Tokens.
- Click Create Token.
- Use the Edit Logs template. You can also use a custom token by enabling the following permissions: Account > Logs > Edit.
- Set the scope to your account or specific zones.
- Copy the generated API token.
Configure Logpush:
- In the Cloudflare dashboard, go to Analytics & Logs > Logpush.
- Click Create a Logpush Job.
- Choose HTTP Requests dataset.
- Select HTTP destination.
- In the destination URL field, enter:
https://api.openobserve.ai/api/your_organization_id/cloudflare_logs/_json
-
Add an Authorization header with the following values:
- Key: Authorization
- Value: Basic
To encode your credentials, use the following command in a terminal:
Verify Logs in OpenObserve
- Log in to OpenObserve.
- Go to Logs.
- From the stream selector dropdown, select cloudflare_logs.
- Select the time range.
- Click Run Query. You should see entries similar to the following:

Logs appear immediately when using Logpush. If you are testing with GraphQL, the simulated data appears first. Real logs are usually visible within 5 to 10 minutes.
Troubleshooting
GraphQL Integration:
- If the message No logs yet appears, check traffic under Analytics > Traffic.
- If an API Error occurs, examine the full response using response.text.
Logpush Integration:
- Confirm the destination endpoint and authentication values in the Logpush job settings.
No Logs in OpenObserve:
- Verify that the organization ID and credentials are correct.