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
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
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.
| authentication_method | failure_reason | attempts | affected_actors | failed_attempts | failure_rate_pct |
|---|---|---|---|---|---|
| sso | provider_timeout | 20 | 20 | 8 | 40 |
| password | invalid_credential | 20 | 20 | 5 | 25 |
| passkey | user_cancelled | 20 | 20 | 2 | 10 |
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, reproducible input rows, exact SQL, expected output, review notes, and engine version. The CSV contains the displayed result.
How the SQL works
- 1A rolling 24-hour window makes a broken method 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
Define the source data
Event schemas for this analysis
Continue the analysis
Audit AI Agent Tool Authorization Decisions
Review allowed, denied, and approval-required agent tool decisions by risk class without collecting prompts, tool arguments, results, or credentials.
Open recipeAudit Privileged Actions with SQL
Summarize sensitive administrative actions, denied attempts, and review-required outcomes without collecting raw secrets or resource contents.
Open recipeDetect Suspicious Authentication Bursts
Find short authentication windows with repeated failures across many identities or coarse network sources.
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.