Telemetry
Structured events SQL recipe

Detect Missing Service Heartbeats

Find services, workers, or scheduled tasks that stopped reporting before a failure event appeared.

Beginnerservice_heartbeatsReviewed 2026-07-27Tested with Apache DataFusion 45.2.0

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

Question answered

Which expected telemetry sources have stopped sending heartbeats?

Silence is often the first symptom of a crashed process or broken ingestion path. This query compares the newest heartbeat for each source with an expected reporting interval.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampWhen the heartbeat was observed.
service_nameUtf8Stable source or service name.
environmentUtf8production, staging, or development.
statusUtf8healthy or degraded at heartbeat time.
DataFusion SQL

Copy the query

sql
SELECT
  service_name,
  environment,
  MAX(timestamp_utc) AS last_seen_at,
  COUNT(*) AS heartbeats_in_window
FROM service_heartbeats
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
  AND environment = 'production'
GROUP BY service_name, environment
HAVING MAX(timestamp_utc) < now() - INTERVAL '10 minutes'
ORDER BY last_seen_at ASC;

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

Production sources past the heartbeat deadline

The oldest last_seen_at value should be investigated first.

service_nameenvironmentlast_seen_atheartbeats_in_window
billing_syncproduction2026-07-27 15:04:00Z132
email_workerproduction2026-07-27 15:11:00Z139

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

Production sources past the heartbeat deadline: static chart of synthetic last_seen_at values from the Detect Missing Service Heartbeats 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, illustrative input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.

How the SQL works

  1. 1MAX(timestamp_utc) returns the newest observed heartbeat for each source.
  2. 2HAVING filters after grouping, keeping only services whose newest event is older than the allowed silence window.
  3. 3The count provides useful context: a source with no events in the entire lookback window may need an expected-sources table rather than this event-only query.

Edge cases to decide

  • A source that has never emitted a heartbeat cannot appear. Maintain an expected source registry when complete coverage matters.
  • Set the threshold above the normal interval plus ingestion and scheduling jitter.
  • Separate planned maintenance or disabled workers to avoid noisy alerts.

Recommended dashboard

  • Stat: number of sources past deadline
  • Table: last_seen_at by service_name
  • Line chart: heartbeat volume by source

Alert guidance

Alert after two or three expected intervals are missed, and include the last-seen time and runbook link.

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