Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Dependency call completion time. |
| dependency_name | Utf8 | Stable logical dependency name. |
| operation | Utf8 | Normalized operation or route. |
| status | Utf8 | success, failed, or timeout. |
| latency_ms | Float64 | Dependency duration in milliseconds. |
Copy the query
SELECT
dependency_name,
operation,
COUNT(*) AS calls,
approx_percentile_cont(latency_ms, 0.50) AS p50_ms,
approx_percentile_cont(latency_ms, 0.95) AS p95_ms,
100.0 * SUM(CASE WHEN status <> 'success' THEN 1 ELSE 0 END)
/ NULLIF(COUNT(*), 0) AS failure_rate_pct
FROM dependency_calls
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
GROUP BY dependency_name, operation
HAVING COUNT(*) >= 50
ORDER BY p95_ms DESC
LIMIT 20;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
Dependency p95 latency
Invoice history has a severe long tail despite an acceptable median.
| dependency_name | operation | calls | p50_ms | p95_ms | failure_rate_pct |
|---|---|---|---|---|---|
| billing_database | invoice_history | 1,840 | 84 | 1,820 | 0.49 |
| search_provider | document_search | 6,220 | 132 | 760 | 1.21 |
| redis | session_lookup | 44,100 | 3 | 12 | 0.02 |
Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.
How the SQL works
- 1Grouping by logical dependency and operation keeps the result actionable.
- 2The gap between p50 and p95 distinguishes consistently slow services from intermittent tail behavior.
- 3Failure rate prevents a fast-failing dependency from appearing healthy.
Edge cases to decide
- Avoid raw SQL text, full URLs, or customer identifiers in operation names.
- Parallel dependency calls do not add linearly to request duration.
- If traces already contain this timing, record only the business context needed to connect the outcome.
Recommended dashboard
- Grouped bars: p50_ms and p95_ms by dependency
- Trend: p95 latency and failure rate
- Table: slow dependency calls with route, release, and trace ID
Alert guidance
Alert when a critical dependency exceeds its p95 objective and is affecting a minimum number of calls.
Read alert setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Calculate API Error Rate by Route
Use SQL to rank API routes by 5xx error rate while protecting the result from low-volume noise.
Open recipeCalculate p50, p95, and p99 API Latency
Compare median and tail latency by endpoint with DataFusion-compatible percentile SQL.
Open recipeCalculate API Error-Budget Burn Rate
Turn hourly request failures into an SLO burn-rate series that shows how quickly the allowed error budget is being consumed.
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.