Cloudflare Analytics Engine
Write analytics events from Workers and query with SQL — time-series storage without managing infrastructure.
Why
Analytics Engine ingests millions of events/sec from Workers and lets you SQL-query them — no Clickhouse/Kafka to run. Free tier: 10M writes/day, pay per query.
Perfect for product analytics and API metrics.
When
Use for API request metrics, feature adoption tracking, and per-user analytics. Avoid for high-cardinality data (unique user IDs as indexes bloat storage).
How
Example
Common Problems
- ⚠High-cardinality indexes — using user IDs as indexes bloats storage, use blobs instead
- ⚠Write rate limits — 1000 writes/sec per Worker, batch with writeDataPoint array
- ⚠Query latency on large datasets — time-bound queries with WHERE timestamp, avoid full scans
Best Practices
- ✓Use indexes for low-cardinality filters — API version, env, region; not user IDs
- ✓Batch writes — collect events in array, write once per request via ctx.waitUntil
- ✓Pre-aggregate in Workers — write rollups (count, sum) not raw events, reduces storage 100x
FAQ
What is Cloudflare Analytics Engine and what problem does it solve?
Write analytics events from Workers and query with SQL — time-series storage without managing infrastructure. It lets developers deploy, store, and scale without self-managing infrastructure — a core reference for cloud service selection.
How do I get started with Cloudflare Analytics Engine in 5 minutes?
Two steps to run it: (1) Create dataset — wrangler analytics-engine create my-dataset; (2) Bind — [[analytics_engine_datasets]] binding="ANALYTICS" dataset="my-dataset". Validate on the free tier first, then wire into production.
What is the #1 pitfall with Cloudflare Analytics Engine?
The most frequent issue is: High-cardinality indexes — using user IDs as indexes bloats storage, use blobs instead. Run a pre-launch checklist item by item, and add policy/config scanning in CI.
What are the best practices for Cloudflare Analytics Engine?
Best practices for Cloudflare Analytics Engine include: Use indexes for low-cardinality filters — API version, env, region; not user IDs; Batch writes — collect events in array, write once per request via ctx.waitUntil; Pre-aggregate in Workers — write rollups (count, sum) not raw events, reduces storage 100x. The first one — "Use indexes for low-cardinality filters — API version, env, region; not user IDs" — should be a team default baked into your IaC templates.
How do I control cost and avoid bill surprises with Cloudflare Analytics Engine?
Three ways to prevent overspend: (1) tag every resource with env/team and enable billing alarms; (2) set budget thresholds to trigger Slack/email alerts; (3) review idle resources in Cost Explorer regularly and clean them up. Most Cloudflare Analytics Engine options offer a free tier — validate within free quota before scaling.