Skip to content
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 . We checked the SQL syntax, required event fields, sample results, and limits on using the query. Who reviews this page

Question answered

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

Service error rates do not identify affected customers. Record the incident, pseudonymous account, plan, approved impact category, and duration so responders can plan recovery and contact affected accounts.

Event schema

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. We review the synthetic sample output separately. Check field types, thresholds, and counting rules 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
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. 1The assessed-account denominator prevents an incomplete join from masquerading as a low impact rate.
  2. 2Group by plan to help prioritize follow-up. 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 check

  • 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

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