Telemetry
Infrastructure SQL recipe

Find Kubernetes Restarts by Workload

Rank Kubernetes workloads by container restart events, readiness failures, and observed cumulative restart count.

Beginnerkubernetes_workload_eventsReviewed 2026-07-28Tested with Apache DataFusion 45.2.0

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

Question answered

Which Kubernetes workloads are restarting and failing readiness checks?

A restart counter alone does not show when the change occurred or whether users were affected. This event pattern keeps restart transitions and readiness samples together at the workload boundary so a reviewer can identify sustained instability.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampSample or transition time in UTC.
clusterUtf8Controlled cluster name.
namespaceUtf8Kubernetes namespace.
workloadUtf8Deployment, StatefulSet, or Job owner name.
podUtf8Pod identifier for restricted drill-downs.
event_nameUtf8Controlled sampled or container_restarted event.
restart_countInt64Observed cumulative container restart count.
readyBooleanWhether the pod was ready at the sample.
environmentUtf8Deployment environment.
DataFusion SQL

Copy the query

sql
SELECT
  cluster,
  namespace,
  workload,
  COUNT(*) AS observations,
  SUM(CASE WHEN event_name = 'container_restarted' THEN 1 ELSE 0 END) AS restart_events,
  MAX(restart_count) AS max_restart_count,
  SUM(CASE WHEN ready THEN 0 ELSE 1 END) AS not_ready_observations,
  100.0 * SUM(CASE WHEN ready THEN 0 ELSE 1 END)
    / NULLIF(COUNT(*), 0) AS not_ready_rate_pct
FROM kubernetes_workload_events
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
  AND environment = 'production'
GROUP BY cluster, namespace, workload
ORDER BY restart_events DESC, not_ready_rate_pct DESC, workload;

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

Restart and readiness signals by workload

Checkout has more restart transitions and not-ready observations than the billing worker.

clusternamespaceworkloadobservationsrestart_eventsmax_restart_countnot_ready_observationsnot_ready_rate_pct
production-usapplicationcheckout-api524240
production-usapplicationbilling-worker412125

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

Restart and readiness signals by workload: static chart of synthetic restart_events values from the Find Kubernetes Restarts by Workload 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, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.

How the SQL works

  1. 1Workload ownership is more stable than pod names and maps the result to a deployable unit.
  2. 2Restart transitions are counted separately from the cumulative counter to avoid summing gauges.
  3. 3Readiness observations keep the operational symptom beside a potential serving impact.

Edge cases to decide

  • A rollout naturally replaces pods; distinguish planned replacement from repeated container restart.
  • Counters can reset when pods are recreated, so use transition events for rates.
  • Join deployment and application-release context before attributing a restart to a code change.

Recommended dashboard

  • Stacked bars: restart_events and not_ready_observations by workload
  • Trend: restart transitions by cluster and namespace
  • Table: latest affected pods with release and controlled reason

Alert guidance

Alert on repeated restart transitions plus sustained readiness loss, not on an isolated rollout replacement.

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