Skip to content
Telemetry
API reliability SQL recipe

Calculate API request throughput by route

Calculate observed requests per minute by stable API route and keep error volume beside throughput.

Beginnerapi_throughput_eventsReviewed 2026-07-28Tested with Apache DataFusion 45.2.0

Reviewed by the Telemetry product team on . We checked the SQL syntax, required event fields, sample results, and limits on using the query. Who reviews this page

Question answered

Which API routes are processing the most requests per minute?

Throughput is most useful when it preserves route shape and the time actually observed. This query divides request volume by each route's observed span instead of assuming every route was active for the entire dashboard window.

Event schema

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampRequest completion time in UTC.
route_templateUtf8Bounded route template, never the raw URL.
status_codeInt64HTTP response status.
environmentUtf8Deployment environment.
DataFusion SQL

Copy the query

sql
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. We review the synthetic sample output separately. Check field types, thresholds, and counting rules 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_templaterequestserrorsrequests_per_minute
/api/search610.2
/api/checkout400.13

Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.

Observed request throughput by route: static chart of synthetic requests_per_minute values from the Calculate API request throughput by route example result
Download this SVG chart of the sample results for an article, runbook, or design review. Please credit Telemetry.

Reproduce the example

Download the sample data

The JSON bundle includes the event schema with field types, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.

How the SQL works

  1. 1Grouping on a controlled route template avoids one series per resource identifier or query string.
  2. 2The denominator uses the observed span for each route, which is safer for sparse routes than dividing by the whole lookback window.
  3. 3Keep error count beside error rate for each group so you can compare traffic changes with reliability.

Edge cases to check

  • 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 setup

Set up the events this query needs

Related instrumentation and guides

Continue the analysis

Run it on your 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.

Get an API key