Telemetry
SQL recipe collection

Data quality SQL recipes

Detect stale ingestion, duplicate identifiers, missing required fields, delayed events, and instrumentation regressions before dashboards become misleading.

Common event contract

Fields that keep these queries reusable

  • timestamp_utc, received_at, event_id, event_name, and schema_version
  • source, environment, producer_version, and required business fields
  • ingestion_status, validation_error, and duplicate outcome

Definitions before SQL

Decisions the query cannot make for you

  1. 1Define expected event volume and freshness separately for each source.
  2. 2Choose stable event identifiers before attempting deduplication.
  3. 3Measure field completeness only where the field is truly required.

Recommended sequence

Build detection first, then diagnosis

Analysis patterns

Make the result explain a decision

Monitor the telemetry itself

Treat freshness, completeness, uniqueness, and schema adoption as first-class signals beside the product metrics they support.

Separate event time from receipt time

Compare when work happened with when it arrived to expose delayed clients, backfills, and blocked ingestion.

Segment by producer

Break regressions down by source, environment, schema version, or release so the owner and rollout boundary are clear.

Complete recipes

Copy the query, then validate the assumptions

Beginnertelemetry_events

Measure Event Ingestion Freshness

Find event sources that stopped delivering data or are arriving substantially later than they occurred.

Which production event sources are stale or delayed right now?

See SQL and result
Beginnertelemetry_events

Find Duplicate Event IDs

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

Which event IDs were received more than once?

See SQL and result
Beginnerproduct_events

Measure Required-Field Null Rate

Find event contracts where a required account, status, or correlation field is disappearing.

Which event names have an unacceptable missing account identifier rate?

See SQL and result
Intermediateingestion_events

Measure Late-Arriving Events

Measure event delivery delay by source and identify producers that send stale or out-of-order data.

Which event producers deliver data late enough to distort analysis?

See SQL and result
Beginnerproduct_events

Track Event Schema-Version Adoption

Measure schema-version rollout by producer and find old event contracts that remain active after a deployment.

Which producers still emit old versions of a critical event?

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.