Telemetry
SQL recipe collection

API reliability SQL recipes

Calculate request error rates, latency percentiles, release regressions, error budgets, and customer impact from structured API events.

Common event contract

Fields that keep these queries reusable

  • timestamp_utc, route_template, method, and status_code
  • latency_ms, request_id, release, environment, and dependency
  • team_id or account_id when customer-impact analysis is approved

Definitions before SQL

Decisions the query cannot make for you

  1. 1Define which responses count as failures before calculating a rate.
  2. 2Set a minimum request volume so quiet routes do not dominate percentages.
  3. 3Keep route templates and releases stable enough to compare over time.

Recommended sequence

Build detection first, then diagnosis

Analysis patterns

Make the result explain a decision

Normalize by request volume

Pair failure counts with rates and a minimum-volume threshold so a quiet route cannot outrank a genuinely risky endpoint.

Compare stable dimensions

Group by route template, release, dependency, or environment instead of raw URLs and other unbounded values.

Connect detection to impact

Start with a service-level change, then identify the customers, releases, and dependencies that contributed to it.

Complete recipes

Copy the query, then validate the assumptions

Beginnerapi_requests

Calculate API Error Rate by Route

Use SQL to rank API routes by 5xx error rate while protecting the result from low-volume noise.

Which API routes have the highest meaningful 5xx error rate?

See SQL and result
Intermediateapi_requests

Calculate p50, p95, and p99 API Latency

Compare median and tail latency by endpoint with DataFusion-compatible percentile SQL.

Which endpoints have the worst tail latency?

See SQL and result
Intermediateapi_requests

Calculate 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.

How quickly is the API consuming its 99.9% availability budget?

See SQL and result
Intermediateapi_requests

Compare API Reliability by Release

Compare traffic, 5xx rate, and p95 latency across application releases without attributing every post-deploy change to the deploy.

Which releases coincide with worse API errors or tail latency?

See SQL and result
Beginnerapi_requests

Rank Error Fingerprints by Customer Impact

Rank normalized application errors by occurrences and affected accounts instead of letting one retry loop dominate the incident view.

Which error groups affect the most customer accounts?

See SQL and result
Beginnerapi_requests

Calculate API Timeout Rate by Route

Rank routes by timeout rate while preserving request volume and configured timeout boundaries.

Which API routes time out often enough to affect users?

See SQL and result
Intermediatedependency_calls

Compare Dependency p95 Latency

Find databases, APIs, caches, and queues contributing the most tail latency to requests.

Which downstream dependencies have the worst tail latency and failure rate?

See SQL and result
Intermediateapi_requests

Measure API Availability Against an SLO

Calculate daily availability and show whether a service met its explicit objective.

Did each service meet its daily availability objective?

See SQL and result
Beginnerapi_throughput_events

Calculate API Request Throughput by Route

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

Which API routes are processing the most requests per minute?

See SQL and result
Intermediateapi_attempt_events

Measure API 429 Rate-Limit Recovery

Measure how often rate-limited requests recover on a later attempt without treating every retry as a new request.

Do requests that receive HTTP 429 recover successfully after retrying?

See SQL and result
Beginnerfeature_rollout_events

Compare Feature Rollout Error Rate

Compare request errors and average latency between feature-flag rollout and control cohorts for one release.

Is the feature-flag rollout less reliable than its control cohort?

See SQL and result
Intermediateincident_account_impact_events

Measure Incident Customer Impact by Plan

Count affected accounts and average impact duration by plan without exposing customer names or raw request data.

How many accounts were affected by the incident in each plan?

See SQL and result

Adapt the event contract before the threshold

Keep the analysis pattern, but validate table names, field types, business definitions, time windows, and minimum-volume rules against your own events. Every published query is also planned and executed against an empty typed table with the pinned engine.