Event contract
Fields the query expects
| Field | Type | Why it exists |
|---|---|---|
| timestamp_utc | Timestamp | Final policy-decision time in UTC. |
| workflow | Utf8 | Versioned, low-cardinality agent workflow. |
| tool_name | Utf8 | Approved low-cardinality tool identifier. |
| action_class | Utf8 | Controlled class such as read_only or external_state_change. |
| risk_level | Utf8 | Reviewed low, medium, or high risk class. |
| decision | Utf8 | Allowed, denied, or approval_required. |
| reason_code | Utf8 | Controlled policy reason without a free-form model explanation. |
| policy_version | Utf8 | Version of the policy contract used for the decision. |
| environment | Utf8 | Deployment environment. |
Copy the query
SELECT
tool_name,
risk_level,
COUNT(*) AS decisions,
SUM(CASE WHEN decision = 'denied' THEN 1 ELSE 0 END) AS denied,
SUM(CASE WHEN decision = 'approval_required' THEN 1 ELSE 0 END) AS approval_required,
SUM(CASE WHEN decision = 'allowed' THEN 1 ELSE 0 END) AS allowed,
100.0 * SUM(CASE WHEN decision = 'denied' THEN 1 ELSE 0 END)
/ NULLIF(COUNT(*), 0) AS denial_rate_pct
FROM agent_tool_authorization_decisions
WHERE timestamp_utc >= now() - INTERVAL '30 days'
AND environment = 'production'
GROUP BY tool_name, risk_level
ORDER BY denied DESC, approval_required DESC, tool_name;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
Agent tool denial rate
Synthetic decisions keep denial rate beside approval and total volume for each tool.
| tool_name | risk_level | decisions | denied | approval_required | allowed | denial_rate_pct |
|---|---|---|---|---|---|---|
| database_write | high | 4 | 2 | 1 | 1 | 50 |
| filesystem_write | high | 4 | 1 | 2 | 1 | 25 |
| web_search | medium | 3 | 0 | 0 | 3 | 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
- 1The decision is emitted by the authorization layer before execution, not inferred from the model's requested action.
- 2Tool name, risk level, reason code, and policy version use controlled values so policy changes remain comparable.
- 3Counts remain visible beside denial rate because a high percentage over a few decisions should not trigger an automatic escalation.
Edge cases to decide
- An expected denial can show policy working; define reviewed escalation conditions before alerting.
- Log the terminal tool outcome separately so an allowed decision is not mistaken for successful execution.
- Keep prompts, arguments, results, credentials, retrieved documents, and free-form policy explanations outside general telemetry.
Recommended dashboard
- Bars: denial_rate_pct by tool_name
- Stacked decisions: allowed, denied, and approval_required by risk_level
- Trend: decision mix by policy_version and release
Alert guidance
Alert only on reviewed conditions such as a sustained high-risk denial spike, a novel tool class, or an overdue approval queue with sufficient volume.
Read alert setupPut the recipe to work
Related instrumentation and guides
Define the source data
Event schemas for this analysis
Continue the analysis
Analyze Authentication Failure Rate
Measure authentication failures by method and reason while keeping traffic volume and affected identities visible.
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.