Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Request completion time in UTC. |
| route_template | Utf8 | Bounded route template, never the raw URL. |
| status_code | Int64 | HTTP response status. |
| environment | Utf8 | Deployment environment. |
Copy the query
SELECT
route_template,
COUNT(*) AS requests,
SUM(CASE WHEN status_code >= 500 THEN 1 ELSE 0 END) AS errors,
60.0 * COUNT(*) / NULLIF(
date_part('epoch', MAX(timestamp_utc) - MIN(timestamp_utc)),
0
) AS requests_per_minute
FROM api_throughput_events
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
AND environment = 'production'
GROUP BY route_template
ORDER BY requests_per_minute DESC, route_template;This read-only query is planned and executed against an empty typed table with Apache DataFusion 45.2.0. The deterministic sample output is synthetic and reviewed separately; validate field types, thresholds, and business definitions against your own data. Read the testing methodology.
Query result
Observed request throughput by route
Search carries the highest observed request rate and also has a 5xx response to investigate.
| route_template | requests | errors | requests_per_minute |
|---|---|---|---|
| /api/search | 6 | 1 | 0.2 |
| /api/checkout | 4 | 0 | 0.13 |
Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.
Reproduce the example
Download the public fixture
The JSON bundle includes the typed event contract, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.
How the SQL works
- 1Grouping on a controlled route template avoids one series per resource identifier or query string.
- 2The denominator uses the observed span for each route, which is safer for sparse routes than dividing by the whole lookback window.
- 3Error count stays in the result so a traffic surge can be compared with reliability at the same grain.
Edge cases to decide
- For production charts, aggregate into complete fixed time buckets so adjacent periods are directly comparable.
- A route with one request has no observed span; NULLIF returns null instead of inventing a rate.
- Separate internal health checks and synthetic traffic if they would distort customer demand.
Recommended dashboard
- Trend: requests per minute in complete five-minute buckets
- Bars: requests_per_minute by route_template
- Overlay: error rate and deployment markers
Alert guidance
Alert on sustained deviation from a reviewed baseline, not on a single high-volume route.
Read alert setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Calculate API Error Rate by Route
Use SQL to rank API routes by 5xx error rate while protecting the result from low-volume noise.
Open recipeCalculate p50, p95, and p99 API Latency
Compare median and tail latency by endpoint with DataFusion-compatible percentile SQL.
Open recipeCalculate API Error-Budget Burn Rate
Turn hourly request failures into an SLO burn-rate series that shows how quickly the allowed error budget is being consumed.
Open recipeRun it on real events
Create a table, adapt the fields, and save the result
Start free, send structured events, and use the query result as a chart, shared dashboard widget, or alert input.