Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Action completion time in UTC. |
| actor_role | Utf8 | Bounded role class; avoid email addresses in broad reporting tables. |
| action | Utf8 | Controlled privileged-action name. |
| resource_type | Utf8 | Resource class without raw resource contents. |
| outcome | Utf8 | Terminal success, denied, or failed outcome. |
| requires_review | Boolean | Whether policy requires a human review. |
| environment | Utf8 | Deployment environment. |
Copy the query
SELECT
action,
COUNT(*) AS actions,
SUM(CASE WHEN outcome <> 'success' THEN 1 ELSE 0 END) AS failed_actions,
SUM(CASE WHEN requires_review THEN 1 ELSE 0 END) AS review_required,
100.0 * SUM(CASE WHEN outcome <> 'success' THEN 1 ELSE 0 END)
/ NULLIF(COUNT(*), 0) AS failure_rate_pct
FROM security_audit_events
WHERE timestamp_utc >= now() - INTERVAL '30 days'
AND environment = 'production'
GROUP BY action
ORDER BY failed_actions DESC, failure_rate_pct DESC, action;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
Privileged-action failure rate
Data exports have the highest denied or failed share in the synthetic review set.
| action | actions | failed_actions | review_required | failure_rate_pct |
|---|---|---|---|---|
| data_exported | 2 | 1 | 1 | 50 |
| permissions_changed | 3 | 1 | 2 | 33.33 |
| api_key_created | 2 | 0 | 1 | 0 |
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
- 1Controlled action names make the report stable enough for policy reviews and alerts.
- 2Failure rate is shown beside absolute review volume so a rare action does not create false urgency.
- 3Role and resource class support investigation without putting credentials, object contents, or unrestricted identifiers in the reporting result.
Edge cases to decide
- Define whether policy-denied actions are expected controls or incidents before alerting.
- Keep immutable source records and retention policy outside this aggregate query.
- Use approved actor identifiers only in restricted drill-downs with access logging.
Recommended dashboard
- Bars: failure_rate_pct by privileged action
- Trend: denied and failed actions by day
- Review queue: requires_review by action and actor_role
Alert guidance
Alert on a new action class, repeated denied attempts, or review backlog after the security owner approves thresholds.
Read alert setupPut the recipe to work
Related instrumentation and guides
Continue the analysis
Analyze Authentication Failure Rate
Measure authentication failures by method and reason while keeping traffic volume and affected identities visible.
Open recipeDetect Suspicious Authentication Bursts
Find short authentication windows with repeated failures across many identities or coarse network sources.
Open recipeAnalyze Access-Policy Denials
Rank denied actions by policy, resource class, actor role, and affected identities.
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.