cloudflare-log-collector

Firewall Events HTTP Traffic Stats Prometheus Metrics Loki Log Streams OpenTelemetry Tracing
Cloudflare analytics for your self-hosted stack
A lightweight Go service that polls the Cloudflare GraphQL Analytics API for firewall events and HTTP traffic statistics, ships them into a self-hosted observability stack, and traces every poll cycle with OpenTelemetry.
- Firewall events are pushed to Loki as structured JSON log lines for querying in Grafana
- HTTP traffic stats are exposed as Prometheus gauges and also pushed to Loki for raw detail
- Every poll cycle gets its own OpenTelemetry trace with child spans, exported to Tempo via OTLP gRPC
- Log-trace correlation is automatic —
trace_idandspan_idare injected into every structured log line
Key Features
Polls Cloudflare's firewallEventsAdaptive dataset for WAF events with full request detail.
Aggregated request counts grouped by method, status code, and country.
Rich metrics covering poll health, firewall events, HTTP traffic, and Loki push status.
Pushes structured JSON log streams directly to Loki's push API.
Every poll cycle is traced end-to-end with child spans for API calls and Loki pushes.
Automatic trace_id and span_id injection into every structured log line.