Skip to main content

Cloudflare

Cloudflare sits in front of an organisation's public web estate as DNS, CDN, WAF and reverse proxy, which makes it one of the few places where an attack on a public service is visible before it reaches the service. Fluency calls the Cloudflare API on a schedule for two things: the audit log of what administrators changed, and the traffic and firewall roll-ups served by the GraphQL Analytics API. The audit log is the half most organisations underestimate: Cloudflare is a control plane for name resolution and traffic routing, so an attacker who reaches it can repoint a hostname or switch off a firewall rule without touching a single server, and nothing on those servers records it happening.

Authentication is an API token scoped to the account, with read permissions only; the one decision is whether the token belongs to a user or to the account (step 2).

The setup has two halves:

  1. In Cloudflare: as someone who can create API tokens for the account, create a custom token under Manage Account → API Tokens (account-owned) with Audit Logs: Read and Account Analytics: Read at Account scope, copy the token, and read the Account ID from the dashboard URL.
  2. In Fluency: install the Cloudflare API application template and paste both values in.

What arrives​

StreamWhat it holdsLands in
Audit logDashboard and API activity (DNS records edited, WAF rules disabled, API tokens minted, members added) with who, when and from whereThe template's own index, named in its Actions list
AnalyticsTraffic, firewall and security analytics behind the dashboard's own graphs, as counts per time bucketThe template's own index, named in its Actions list

The analytics are roll-ups, not one record per HTTP request: the individual request comes only from Logpush, which needs Cloudflare's Enterprise plan and its own integration, Cloudflare Log Push (v1: Cloudflare Log Push), alongside this one (roll-ups). Each source needs its own token permission, and a token missing one still collects the other (step 3).

What each source holds, the endpoints and the rate limit are in Reference.

Before you begin​

An account-level administrator, or someone who can create API tokens for the account. A token can only grant permissions its creator holds.

Part 1: Cloudflare​

1. Read the Account ID​

The Account ID is a 32-character hexadecimal identifier. The quickest place to read it is the dashboard URL itself, which is of the form dash.cloudflare.com/<account id>/…. It is also shown in the API panel on the right of any zone's Overview page.

Not the Zone ID

The Account ID and the Zone ID are both 32-character hexadecimal strings, and the API panel shows them one above the other. A Zone ID entered here is well-formed, so nothing rejects it: the install succeeds and collection returns nothing useful.

2. Create the API token​

Cloudflare issues user tokens, which belong to the person who created them and die with their access, and account-owned tokens, which belong to the account itself. Use an account-owned token, so the integration keeps working after the person who set it up changes roles; the choice also decides which verification call applies.

For a user token: open My Profile → API Tokens → Create Token.

For an account-owned token: open Manage Account → API Tokens → Create Token.

Either way, choose Create Custom Token rather than one of the templates: none of the presets matches what this integration needs.

3. Grant the permissions​

Add these permission rows, all at Account scope:

PermissionAccessWhat it buys
Audit LogsReadThe dashboard and API activity log.
Account AnalyticsReadAccount-scoped datasets in the GraphQL Analytics API.

Under Account Resources, include the account whose ID you read in step 1. The two permissions fail independently: a token missing one still collects the other, so check both rows rather than concluding from one working source that the token is complete.

  • Zone-scoped analytics need a zone permission as well. Some GraphQL datasets are zone-scoped rather than account-scoped. If you want those, add Zone → Analytics → Read and set Zone Resources to All zones from an account; otherwise a zone added next year is silently outside the token's reach.
  • Do not grant edit anywhere. This integration only ever reads. An Edit on any Cloudflare permission group is a token that can change DNS, and it is being stored in a third-party system.

Leave Client IP Address Filtering empty unless you know the egress addresses Fluency will call from and intend to maintain that list.

TTL is optional and defaults to no expiry. A token with a TTL stops working on a date nobody is watching for (Maintenance).

4. Copy the token​

Shown once

Cloudflare displays the token value on the confirmation screen after creation and never again. If you lose it, the only recovery is to Roll the token, which issues a new value and invalidates the old one.

ValueWhere it came from
Account IDThe dashboard URL, or a zone's Overview page (step 1).
API TokenThe confirmation screen in step 4.
Optional: verify the token before you leave Cloudflare

Cloudflare will tell you whether the token is live, which separates a credential problem from an empty feed later. Use the call that matches the token's owner (step 2).

A user token:

curl -s "https://api.cloudflare.com/client/v4/user/tokens/verify" \
-H "Authorization: Bearer $CF_API_TOKEN"

An account-owned token:

curl -s "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/tokens/verify" \
-H "Authorization: Bearer $CF_API_TOKEN"

A healthy answer carries "success": true and a result whose status is active.

Then prove the token can actually see the account you named, which the verify call does not establish:

curl -s "https://api.cloudflare.com/client/v4/graphql" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"query":"query { viewer { accounts(filter:{accountTag:\"'"$CF_ACCOUNT_ID"'\"}) { accountTag } } }"}'

The account tag comes back if the token has account access; an empty accounts array means the token is valid but scoped somewhere else.

ResponseWhat it means
"success": true, status activeThe token works.
"success": false with an authentication errorWrong value, rolled or revoked (step 4).
404 on the account-owned verify pathA user token: use /user/tokens/verify.
Verify succeeds, accounts array emptyAccount resource not included (step 3).
Verify succeeds, GraphQL returns a permission errorAccount Analytics → Read missing (step 3).

One working call does not prove both permissions are on the token (step 3).

Part 2: Fluency​

Install the Application​

In the navigation rail, open Applications and click Install Application, then choose Cloudflare API from the Cloud-based Business Softwares category of the Application Catalog. Both parameters are required and both open empty.

ParameterNotes
Account IDThe 32-character account identifier from step 1, not the Zone ID.
API TokenThe token value from step 4.

Install Cloudflare API form with the Application section&#39;s Instance name and Display name fields, and the Configuration section&#39;s Account ID and API Token fields, above Cancel, Dry run and Install Application

Leave Instance name and Display name at default / Default unless you are installing a second instance (collecting from two Cloudflare accounts, for example), in which case give each one a name you will recognise on the applications list.

Unlike most templates, CloudflareAPI takes no datalake or datalake index name parameter: the destination is fixed by the template rather than chosen on the form, so there is nothing here to collide with another application. To see where the data actually lands, open the installed application's details and read its Actions list, which records every object the install created.

Click Dry run first to have the platform check the account ID and token before anything is installed, then click Install Application. The Applications page opens with the notice Default is launching., and the new application is listed with a green Running badge once the pipeline is up. Click its row to open the application details page, with its Pipeline and Actions.

Confirm it is running​

A Running badge means the pipeline started, not that Cloudflare accepted the token, and analytics volume will not tell you either: a quiet roll-up looks the same as a broken credential (roll-ups).

  1. Generate an audit event you can recognise. Change something harmless in the Cloudflare dashboard (edit a DNS record's comment, rename a page rule) and look for it in the lake. The audit log responds to an action you control, which makes it the better test of the two.
  2. If nothing appears, re-run the verification calls. They distinguish wrong credential from nothing has happened yet, which no view from the Fluency side can.
  3. Search the index the Actions list names. The Actions list in the installed application's details records every object the install created, including where it writes.

See Confirm data is arriving for the general procedure.

Once your test change appears in the index the Actions list names, setup is complete.

Maintenance​

A token with no TTL never expires. A token with one stops working on its end date, Cloudflare does not renew it, and the first symptom is an integration that has been silently collecting nothing, so record the date at install time. Either kind can be revoked or rolled by anyone with account access, and Cloudflare will not tell Fluency that it happened; the token list's Last used time is the quickest way to see whether Fluency is still calling.

Rotating the token​

Template parameters are read-only after install, so a new token means uninstalling and installing again. Cloudflare's Roll action replaces a token's value in place and invalidates the old one immediately, with no overlap, so do it in this order:

  1. In Cloudflare, open the token and use Roll. Copy the new value.
  2. In Fluency, uninstall the Cloudflare API application. To uninstall, click Uninstall at the top right of the application's details page (v1: the red Uninstall button at the foot of its details panel on Platform → Applications).
  3. Install it again with the same Account ID and the new token.

Between steps 1 and 3 the integration is collecting nothing, so keep the window short rather than starting this at the end of a day.

Removing the integration​

Uninstall the application in Fluency first, with the Uninstall button at the top right of its details page (v1: the red Uninstall button at the foot of its details panel on Platform → Applications), then delete the token in Cloudflare. In that order the credential is dead before it is orphaned; in the other order the application spends the interval failing to authenticate.

Troubleshooting​

SymptomLikely causeFix
Running, nothing in the lakeToken wrong, rolled or revokedRe-run the verification calls.
Audit entries arrive, analytics does notAccount Analytics → Read missing from the tokenAdd it (step 3); an edit keeps the Token ID and value, so no reinstall. Allow a little time before re-testing.
Analytics arrives, audit entries do notAudit Logs → Read missing from the tokenAs above.
Nothing arrives, verify says activeAccount resource not included, or a Zone ID entered as the Account IDCheck step 1 and step 3.
It worked, then stopped, nothing changed hereToken rolled, revoked, or past its TTLCheck Last used on the token list (Maintenance).
Per-request HTTP logs never appearNot in this feedUse Logpush (v1: Logpush); see roll-ups.

Reference​

What the two sources look like once they land and how the template reaches them, for searches and detection rules written against them. Where the data lands in your deployment is recorded on the install: open the installed application's details and read its Actions list.

Sources and endpoints
SourceWhat it holdsNotes
Audit logDashboard and API activity: who changed what, when, from wherePer-action records. Account-scoped.
GraphQL Analytics APITraffic, firewall and security analyticsAggregated, not per-request (roll-ups).

Endpoint hosts. api.cloudflare.com/client/v4 for the REST API and api.cloudflare.com/client/v4/graphql for GraphQL, per Cloudflare's own API documentation. The verification calls exercise both.

Roll-ups, not per-request logs

Cloudflare's GraphQL Analytics API answers with counts grouped into time buckets and dimensions: requests by status code, firewall events by action and rule, threats by country. It does not return one record per HTTP request, and no permission on the token changes that.

Per-request records are a different product: Logpush, which Cloudflare gates behind its Enterprise plan and which delivers to a destination you nominate rather than answering a query. If what you need is the individual request (the URI, the client IP, the ray ID), this template is not the feed that carries it. Use Cloudflare Log Push (v1: Cloudflare Log Push) for that, alongside this one if you want both.

Pull and push. This template is the pull side: Fluency calls Cloudflare on a schedule. Logpush is the push side, where Cloudflare sends to you: the Cloudflare Log Push integration type on the Integrations page, which takes no configuration at all, because there the vendor is pointed at the platform rather than the other way round. The two are different feeds rather than alternatives.

Do not use record volume as this integration's health check. Analytics roll-ups arrive at a cadence that has little to do with how much traffic your sites are taking. Confirm it is running gives a check that does not depend on volume.

Rate limits

Cloudflare's global API rate limit is 1,200 requests per five minutes per user, shared across everything calling with that identity. The GraphQL Analytics API applies its own limits on query complexity and time range on top of that. A second application installed against the same account competes for the same budget.

Template

Template ID CloudflareAPI, display name Cloudflare API, description Cloudflare via API / GraphQL, filed under Cloud-based Business Softwares. Two parameters, Account ID and API Token, both required, no datalake or index parameter and therefore no Advanced configuration section on the form (v1: no Advanced Configurations row).

Where it writes. The installed application's Actions list records every object the install created, including the destination index. That is the authoritative answer for your deployment, because the template's destination can change.

Cloudflare documentation

Fluency

Other integrations