Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Authentication outcome time in UTC. |
| actor_id | Utf8 | Privacy-safe stable identity or session identifier. |
| authentication_method | Utf8 | password, oauth, sso, passkey, or another controlled value. |
| outcome | Utf8 | success or failed. |
| failure_reason | Utf8 | Controlled category; never a password or raw provider response. |
| ip_country | Utf8 | Coarse country code derived under the product's privacy policy. |
Copy the query
SELECT
date_trunc('hour', timestamp_utc) AS hour,
authentication_method,
failure_reason,
COUNT(*) AS attempts,
COUNT(DISTINCT actor_id) AS affected_actors,
SUM(CASE WHEN outcome = 'failed' THEN 1 ELSE 0 END) AS failed_attempts,
100.0 * SUM(CASE WHEN outcome = 'failed' THEN 1 ELSE 0 END)
/ NULLIF(COUNT(*), 0) AS failure_rate_pct
FROM authentication_events
WHERE timestamp_utc >= now() - INTERVAL '24 hours'
GROUP BY
date_trunc('hour', timestamp_utc),
authentication_method,
failure_reason
HAVING COUNT(*) >= 20
ORDER BY failed_attempts DESC, failure_rate_pct 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
Authentication failure rate by method
SSO provider timeouts affect many distinct actors and have a materially higher failure rate than expected credential errors.
| hour | authentication_method | failure_reason | attempts | affected_actors | failed_attempts | failure_rate_pct |
|---|---|---|---|---|---|---|
| 2026-07-28 10:00 | sso | provider_timeout | 680 | 412 | 156 | 22.94 |
| 2026-07-28 10:00 | password | invalid_credential | 4,280 | 3,110 | 318 | 7.43 |
| 2026-07-28 10:00 | passkey | user_cancelled | 910 | 842 | 48 | 5.27 |
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
- 1Hourly buckets make a deployment or identity-provider incident visible without exposing individual credentials.
- 2Distinct privacy-safe actor IDs estimate blast radius separately from repeated attempts.
- 3A minimum-volume threshold prevents one unusual attempt from dominating the rate ranking.
Edge cases to decide
- Do not log passwords, tokens, session cookies, full IP addresses, or raw identity-provider payloads.
- Expected user cancellation and suspicious automated attempts need separate reason categories and response policies.
- Country-level segmentation can be sensitive and should be collected only with a documented purpose and retention policy.
Recommended dashboard
- Trend: failure_rate_pct by authentication method
- Bars: affected_actors by controlled failure reason
- Table: newest security events using privacy-safe identifiers
Alert guidance
Alert on a sustained method-level rate and affected-actor threshold; route suspicious behavior through the security response process.
Read alert setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Detect Missing Service Heartbeats
Find services, workers, or scheduled tasks that stopped reporting before a failure event appeared.
Open recipeQuery Nested AI Tool-Call Events
Filter dotted nested fields and rank failing tools without flattening the original event payload.
Open recipeDetect Error-Rate Spikes With a Rolling Baseline
Compare each hourly API error rate with a rolling seven-bucket average instead of relying on one permanent threshold.
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.