Telemetry
Database reliability SQL recipe

Measure Database Connection Timeouts and Churn

Compare connection opens, closes, acquisition timeouts, and affected requests by service and region.

Intermediatedatabase_connection_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 services and regions show unhealthy database connection churn?

Pool saturation shows current pressure; connection lifecycle events explain whether clients are repeatedly reconnecting or timing out before work begins.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampConnection lifecycle event time.
serviceUtf8Application service.
regionUtf8Deployment region.
event_nameUtf8opened, closed, acquisition_timeout, or connection_error.
request_idUtf8Safe affected request identifier.
acquisition_msFloat64Pool acquisition duration when available.
DataFusion SQL

Copy the query

sql
SELECT
  service,
  region,
  SUM(CASE WHEN event_name = 'opened' THEN 1 ELSE 0 END) AS opened,
  SUM(CASE WHEN event_name = 'closed' THEN 1 ELSE 0 END) AS closed,
  SUM(CASE WHEN event_name = 'acquisition_timeout' THEN 1 ELSE 0 END)
    AS acquisition_timeouts,
  SUM(CASE WHEN event_name = 'connection_error' THEN 1 ELSE 0 END)
    AS connection_errors,
  COUNT(DISTINCT CASE
    WHEN event_name IN ('acquisition_timeout', 'connection_error') THEN request_id
  END) AS affected_requests
FROM database_connection_events
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
GROUP BY service, region
ORDER BY acquisition_timeouts DESC, connection_errors DESC;

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

Connection acquisition timeouts

Checkout in us-east has the highest timeout count and lifecycle volume.

serviceregionopenedclosedacquisition_timeoutsconnection_errorsaffected_requests
checkout-apius-east1,8401,7929118104
query-apieu-west62061412416

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

Connection acquisition timeouts: static chart of synthetic acquisition_timeouts values from the Measure Database Connection Timeouts and Churn 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. 1Lifecycle counts reveal reconnect churn beside timeout symptoms.
  2. 2Service and region preserve routing and ownership context.
  3. 3Affected requests keeps infrastructure activity tied to application impact.

Edge cases to decide

  • Normal autoscaling creates expected opens and closes.
  • A request ID may be absent for background pool maintenance.
  • Pool metrics and database connection limits are complementary evidence.

Recommended dashboard

  • Bars: acquisition_timeouts by service
  • Trend: opened and closed by region
  • Table: affected_requests and connection errors

Alert guidance

Alert on sustained acquisition timeouts with affected requests, not normal lifecycle volume alone.

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