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-27

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 recipe is read-only and reviewed against Telemetry's DataFusion query patterns. Sample output is deterministic and synthetic; validate field types, thresholds, and business definitions against your own data.

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.

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