Telemetry
API reliability SQL recipe

Measure Incident Customer Impact by Plan

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

Intermediateincident_account_impact_eventsReviewed 2026-07-28Tested with Apache DataFusion 45.2.0

Reviewed by the Telemetry product team on . SQL compatibility, event contract, synthetic output, and operational caveats. Editorial ownership

Question answered

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

Service-level error rates do not answer who was affected. A bounded impact event connects one incident to a pseudonymous account, plan, controlled impact type, and duration so response teams can prioritize recovery and communication.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampImpact assessment time in UTC.
incident_idUtf8Stable incident identifier.
account_idUtf8Approved pseudonymous account identifier.
planUtf8Bounded plan or service tier.
impact_typeUtf8Controlled customer-visible impact category.
affectedBooleanWhether the account met the documented impact definition.
impact_duration_msInt64Measured impact duration in milliseconds.
environmentUtf8Deployment environment.
DataFusion SQL

Copy the query

sql
SELECT
  incident_id,
  plan,
  COUNT(*) AS assessed_accounts,
  SUM(CASE WHEN affected THEN 1 ELSE 0 END) AS affected_accounts,
  100.0 * SUM(CASE WHEN affected THEN 1 ELSE 0 END)
    / NULLIF(COUNT(*), 0) AS affected_accounts_pct,
  AVG(CASE WHEN affected THEN impact_duration_ms ELSE NULL END)
    AS avg_impact_duration_ms
FROM incident_account_impact_events
WHERE timestamp_utc >= now() - INTERVAL '7 days'
  AND environment = 'production'
GROUP BY incident_id, plan
ORDER BY affected_accounts DESC, plan;

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

Affected accounts by plan

Three enterprise and two starter accounts meet the synthetic incident-impact definition.

incident_idplanassessed_accountsaffected_accountsaffected_accounts_pctavg_impact_duration_ms
incident-checkout-42enterprise437540,000
incident-checkout-42starter524020,000

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

Affected accounts by plan: static chart of synthetic affected_accounts values from the Measure Incident Customer Impact by Plan example result
Indexable SVG of the deterministic example output. Download it for an article, runbook, or design review with attribution.

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

  1. 1The assessed-account denominator prevents an incomplete join from masquerading as a low impact rate.
  2. 2Plan is a bounded prioritization dimension; the query does not expose customer names.
  3. 3Impact duration is calculated only for affected accounts so unaffected rows do not pull the average toward zero.

Edge cases to decide

  • Define affected once using a user-visible outcome, not merely a correlated internal error.
  • One account may have several users or regions; choose the reporting unit before emitting rows.
  • Restrict account-level drill-down and use the aggregate only for approved response workflows.

Recommended dashboard

  • Bars: affected_accounts by plan
  • Trend: newly affected and recovered accounts
  • Restricted table: approved account identifiers and impact type

Alert guidance

Use this query for scoping and escalation after incident detection; do not create a second page for every account-level row.

Read alert setup

Put the recipe to work

Related instrumentation and guides

Continue the analysis

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

Get an API key