Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Connection lifecycle event time. |
| service | Utf8 | Application service. |
| region | Utf8 | Deployment region. |
| event_name | Utf8 | opened, closed, acquisition_timeout, or connection_error. |
| request_id | Utf8 | Safe affected request identifier. |
| acquisition_ms | Float64 | Pool acquisition duration when available. |
Copy the query
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.
| service | region | opened | closed | acquisition_timeouts | connection_errors | affected_requests |
|---|---|---|---|---|---|---|
| checkout-api | us-east | 1,840 | 1,792 | 91 | 18 | 104 |
| query-api | eu-west | 620 | 614 | 12 | 4 | 16 |
Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.
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
- 1Lifecycle counts reveal reconnect churn beside timeout symptoms.
- 2Service and region preserve routing and ownership context.
- 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 setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Find Slow Database Queries by Fingerprint
Rank normalized database operations by slow-query rate, average duration, and worst observed duration without storing raw SQL or parameters.
Open recipeMeasure Database Connection-Pool Saturation
Measure average pool utilization, queued acquisition waits, timeouts, and idle capacity by application service.
Open recipeCalculate Database Transaction Rollback Rate
Compare committed and rolled-back transactions by service while preserving error categories, duration, and affected accounts.
Open recipeRun 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.