Schedule icon
Script icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Cloudflare Edge Rate-Limiting and Abuse Threshold Sentinel

Monitor Cloudflare edge rate-limiting and API abuse spikes with Kestra. Query GraphQL analytics, track GitHub issues, and notify SecOps on Slack.

Categories
CloudInfrastructure

Modern web APIs and SaaS applications rely on Cloudflare Rate Limiting rules to protect origin servers from DDoS flood attacks, brute-force credential stuffing, and unauthorized data scraping. When client traffic triggers rate-limiting rules, Cloudflare serves HTTP 429 Too Many Requests responses at the edge. A sudden surge in 429 status codes indicates either an active adversarial attack or a misconfigured enterprise partner client experiencing broken retry backoff loops. This blueprint queries Cloudflare's GraphQL analytics API hourly, flags anomalous surges in HTTP 429 responses, opens an automated GitHub SecOps investigation ticket, and alerts security teams via Slack.

How it works

  1. check_rate_limits_hourly (io.kestra.plugin.core.trigger.Schedule) initiates the audit every hour (shipped disabled for safe verification).
  2. probe_rate_limit_events (io.kestra.plugin.scripts.python.Script) interrogates Cloudflare's GraphQL Analytics API for httpRequestsAdaptiveGroups filtered by edgeResponseStatus: 429 over the previous hour.
  3. branch_on_rate_limit_surge (io.kestra.plugin.core.flow.If) evaluates whether 429 counts exceeded the operator-defined threshold (is_abuse_surge == true):
    • then: Automatically files a GitHub tracking issue via create_abuse_incident_issue (io.kestra.plugin.github.issues.Create) and alerts the SecOps Slack channel via alert_secops_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Emits an informational log entry (log_traffic_normal) confirming normal baseline traffic.
  4. log_audit_complete (io.kestra.plugin.core.log.Log) records the final audit outcome.
  5. The errors block alerts Slack if Cloudflare API tokens expire or queries fail.

What you get

  • Automated, scheduled auditing of edge security rate-limiting activity.
  • Rapid visibility into distributed botnets and aggressive scraper activity.
  • Consolidated GitHub incident tickets with country breakdown and total request volumes.
  • Real-time Slack notifications with direct ticket hyperlinks.

Who it's for

  • DevSecOps and Application Security Engineers managing Cloudflare WAF and Rate Limiting.
  • Site Reliability Engineers protecting origin server capacity from abuse.
  • API Platform leads monitoring client integration health.

Why orchestrate this with Kestra

Kestra coordinates GraphQL querying, JSON metric transformation, conditional escalation, and chat alerting in a single declarative workflow. It injects API tokens securely, provides complete execution history, and eliminates the need for separate standalone monitoring daemons.

Prerequisites

  • A Cloudflare account with an active Zone and Rate Limiting rules enabled.
  • A Cloudflare API Token with Zone.Analytics:Read permissions.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • CLOUDFLARE_API_TOKEN: Authentication token for Cloudflare GraphQL API.
  • GITHUB_TOKEN: GitHub token used to open incident issues.
  • SLACK_WEBHOOK: Incoming Webhook URL for security alerts.

Inputs

  • zone_id (STRING, default 023e105f4ecef8ad9ca31a8372d0c353): Target Cloudflare Zone identifier.
  • rate_limit_threshold (INT, default 500): Maximum tolerated 429 responses per hour before alerting.
  • target_repository (STRING, default my-org/cloudflare-security-operations): Target GitHub repository for logging incident issues.

Outputs

  • outputs.probe_rate_limit_events.vars.zone_id: Audited Cloudflare Zone ID.
  • outputs.probe_rate_limit_events.vars.total_429_count: Aggregated count of rate-limited requests over the last hour.
  • outputs.probe_rate_limit_events.vars.is_abuse_surge: Boolean indicating whether count exceeded threshold.

Quick start

  1. Configure CLOUDFLARE_API_TOKEN, GITHUB_TOKEN, and SLACK_WEBHOOK in your Kestra namespace.
  2. Import this flow and set zone_id to match an active Cloudflare Zone.
  3. Run the flow manually to verify GraphQL querying and Slack notification delivery.
  4. Enable the check_rate_limits_hourly trigger for continuous rate-limit monitoring.

How to extend

  • Add an automated IP block or Cloudflare Firewall Rule creation task to dynamically block abusive ASNs or CIDRs.
  • Integrate with Datadog or Grafana to correlate Cloudflare 429 surges with origin CPU load.
  • Loop over multiple zones across multiple domains using io.kestra.plugin.core.flow.Loop.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.