Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Database failure time. |
| database_system | Utf8 | Database system. |
| operation_name | Utf8 | Controlled application operation. |
| sqlstate | Utf8 | Portable SQLSTATE code when available. |
| release | Utf8 | Application release. |
| request_id | Utf8 | Safe parent request identifier. |
Copy the query
SELECT
database_system,
release,
operation_name,
sqlstate,
COUNT(*) AS failures,
COUNT(DISTINCT request_id) AS affected_requests
FROM database_error_events
WHERE timestamp_utc >= now() - INTERVAL '7 days'
GROUP BY database_system, release, operation_name, sqlstate
ORDER BY failures DESC, affected_requests 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
Database failures by SQLSTATE
Serialization failures in checkout dominate the release's database errors.
| database_system | release | operation_name | sqlstate | failures | affected_requests |
|---|---|---|---|---|---|
| postgresql | api-88 | checkout | 40001 | 184 | 176 |
| postgresql | api-88 | project-create | 23505 | 62 | 62 |
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
- 1SQLSTATE is safer and more stable than grouping raw error strings.
- 2Operation name preserves application ownership.
- 3Distinct requests estimates customer-facing impact.
Edge cases to decide
- Not every driver exposes SQLSTATE consistently.
- The same SQLSTATE can have different causes.
- Store sanitized error categories, not full statement values or server messages.
Recommended dashboard
- Bars: failures by SQLSTATE
- Trend: failures by release
- Table: affected operations and request counts
Alert guidance
Alert on a new high-volume SQLSTATE after release or a known critical class such as connection failure.
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.