Telemetry
Data quality SQL recipe

Find Duplicate Event IDs

Identify event identifiers delivered more than once and measure whether duplicate handling is working.

Beginnertelemetry_eventsReviewed 2026-07-27Tested with Apache DataFusion 45.2.0

Question answered

Which event IDs were received more than once?

Retries are normal in distributed systems. Duplicate identifiers become a data-quality problem when downstream analysis counts every delivery as a new business outcome.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampEvent occurrence time.
event_idUtf8Stable identifier reused for delivery retries.
event_nameUtf8Event contract name.
sourceUtf8Producer name.
DataFusion SQL

Copy the query

sql
SELECT
  event_id,
  event_name,
  source,
  COUNT(*) AS deliveries,
  MIN(timestamp_utc) AS first_seen_at,
  MAX(timestamp_utc) AS last_seen_at
FROM telemetry_events
WHERE timestamp_utc >= now() - INTERVAL '7 days'
  AND event_id IS NOT NULL
GROUP BY event_id, event_name, source
HAVING COUNT(*) > 1
ORDER BY deliveries DESC, last_seen_at DESC
LIMIT 100;

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

Repeated deliveries by event ID

The invoice event was delivered four times and needs idempotent counting downstream.

event_idevent_namesourcedeliveriesfirst_seen_atlast_seen_at
evt_8f31invoice_paidstripe_webhook412:01:0312:06:44
evt_77acjob_completedbilling_worker210:14:2210:14:39

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

How the SQL works

  1. 1Grouping by event_id exposes retry deliveries without assuming that events close in time are duplicates.
  2. 2Including event_name and source catches producers that accidentally reuse an identifier across different contracts.
  3. 3The first and last timestamps show whether duplicates arrive in a short retry burst or much later.

Edge cases to decide

  • Do not generate a new event ID for every retry if downstream consumers need idempotency.
  • A reused identifier across unrelated events is an instrumentation defect, not a harmless duplicate.
  • If duplicates are removed before storage, emit a separate deduplication outcome so the retry behavior remains observable.

Recommended dashboard

  • Stat: duplicate event IDs in the selected period
  • Bars: duplicate deliveries by source
  • Table: newest repeated identifiers

Alert guidance

Alert when duplicate volume or the maximum delivery count rises above the normal retry baseline.

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