Cloudflare Rulesets
Beta Feature
This input is currently in beta. If you run into any issues, please reach out to product@monad.com.
Ingests rulesets from Cloudflare, including account-level and zone-level rule configurations. This input collects the rulesets themselves, such as WAF, rate limiting, DDoS protection, firewall, and transformation rulesets, across your Cloudflare account or specific zones. It does not collect the individual rules inside each ruleset.
Sync Type: Full Synchronisation
Requirements
- A Cloudflare account with API access
- An API Token with
Account Rulesets:ReadorZone Rulesets:Readpermission - Your Cloudflare Account ID (for account-level rulesets) or Zone IDs (for zone-level rulesets)
- If neither Account ID nor Zone IDs are provided, the input will fetch rulesets from all zones in your account
- If neither Account ID nor Zone IDs are provided, the API token also needs the
Zone>Zone>Readpermission so the input can list your zones
Creating an API Token
- Log in to your Cloudflare dashboard
- Navigate to My Profile > API Tokens
- Click Create Token
- Use the Create Custom Token option
- Configure the token:
- Token name: Give it a descriptive name (e.g., "Monad Rulesets")
- Permissions: Add
Account>Rulesets>Read(for account-level rulesets) orZone>Rulesets>Read(for zone-level rulesets) - If you leave both Account ID and Zone IDs empty, also add
Zone>Zone>Read - Account Resources: Select the specific account(s) or "All accounts"
- Click Continue to summary and then Create Token
- Copy the token value (you won't be able to see it again)
Finding Your Account ID and Zone IDs
Account ID:
- Log in to your Cloudflare dashboard
- Select the account you want to monitor
- The Account ID is displayed in the right sidebar on the overview page
- Alternatively, find it in the URL:
https://dash.cloudflare.com/{account_id}/...
Zone IDs:
- Log in to your Cloudflare dashboard
- Click on the domain (zone) you want
- The Zone ID is displayed in the right sidebar on the overview page
- Alternatively, find it in the API call responses
Details
- State Management: Fetches the complete inventory of rulesets on each run. Every run collects all rulesets again, including ones that have not changed since the previous run.
- Scope Options:
- Account-level rulesets: Retrieved from
/accounts/{account_id}/rulesets - Zone-level rulesets: Retrieved from
/zones/{zone_id}/rulesets - All zone rulesets: When no Account ID or Zone IDs are specified, fetches from all zones
- Account-level rulesets: Retrieved from
- Zone limit: When neither Account ID nor Zone IDs is set, the input reads only the first 20 zones Cloudflare returns for the token. To collect rulesets from more than 20 zones, list every zone's ID in Zone IDs.
- Pagination: Cursor-based pagination with up to 50 records per page
- Rule Phases: Retrieves rulesets across all phases including ddos_l4, ddos_l7, http_config_settings, http_request_firewall_custom, http_request_firewall_managed, http_request_transform, http_response_headers_transform, and others
- Rate Limits: Standard Cloudflare API rate limits apply (see Rate Limits section below)
Configuration
Settings
| Setting | Type | Required | Default | Description |
|---|---|---|---|---|
account_id | string | No | - | Your Cloudflare account ID (for account-level rulesets). |
zone_ids | array of string | No | - | List of zone IDs (for zone-level rulesets). If empty and Account ID is not specified, fetches from all zones. |
cron | string (cron) | Yes | 0 * * * * | Cron string for scheduling the ingest of your input. eg: 0 0 * * * - Daily at midnight, or */15 * * * * - Every 15 minutes. Defaults to an hour. |
use_synthetic_data | bool | No | false | Generate synthetic data for testing, instead of connecting to a real data source. Defaults to an hourly cron schedule for cron-based inputs. |
rate_limit | object | No | - | Maximum outbound source-API request rate. A blank or zero value falls back to the connector's default rate-limiting behavior. Maximum 4 requests per second. See API Rate Limiting for the field format. |
Secrets
| Secret | Type | Required | Description |
|---|---|---|---|
api_token | secret | Yes | Your Cloudflare API token with Rulesets |
Rate Limits
| Scope | Limit | Window | Notes |
|---|---|---|---|
| API Requests | 1,200 | per 5 minutes | Standard rate limit across Cloudflare API |
| Rulesets Endpoint | 4 | requests per second | Rate limit specific to rulesets API endpoints |
Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
Source: Cloudflare API Rate Limits
Troubleshooting
Common Issues
Issue: API returned success=false with authentication error
Cause: The API token is invalid, expired, or lacks the required permissions.
Solution: Verify your API token is correct and has Account Rulesets:Read or Zone Rulesets:Read permissions. Create a new token with the proper permissions if needed.
Issue: No rulesets found error
Cause: The specified Account ID or Zone IDs don't exist, or there are no rulesets configured.
Solution: Verify your Account ID and Zone IDs are correct in the Cloudflare dashboard. Ensure rulesets exist in the zones you're querying.
Issue: Rate limit exceeded (429 error) Cause: Too many requests to the rulesets API endpoint within the rate limit window. Solution: Increase the cron schedule interval to reduce the frequency of syncs. The input respects the 4 RPS limit on the rulesets endpoint.
Issue: API access not available
Cause: Your API token lacks the required rulesets permissions.
Solution: Create a new token with Rulesets:Read permissions for either accounts or zones depending on your needs.
Related Articles
- Cloudflare Rulesets API Documentation
- Cloudflare Rulesets Guide
- Cloudflare API Tokens
- Cloudflare API Rate Limits
Sample Record
Code
Sync frequency
This input runs on a cron schedule (default hourly, 0 * * * *), which you can configure on the pipeline.
See Input Sync Frequency for details.
Community transforms
The Monad Transforms Repository has ready-made transforms for this input. Import one into your organization, then add it to a pipeline after this input.
| Format | Transform |
|---|---|
| OCSF v1.9.0 | Cloudflare Rulesets to OCSF v1.9.0 |
| ECS v9.5.0 | Cloudflare Rulesets to ECS v9.5.0 |
| CEF | Cloudflare Rulesets to CEF |
CEF transforms emit an intermediate record; add the CEF Serializer transform after one to produce the CEF:0 string.