Set up AI agent observability template and check the results
Use the prompt to add events, then check the stored fields and query results. Review the event definitions before relying on the numbers.
- 1
Choose when to log
Instrument the point where agent_run_started becomes final.
- 2
Create the contract
Start with agent_run_started, agent_tool_called, agent_run_completed and keep every field typed, bounded, and privacy-reviewed.
- 3
Run a fixture
Exercise known success, failure, retry, and empty-result cases before relying on aggregate results.
- 4
Answer the question
Which tools fail most often?
Template versus use case
Use this template to add events
Copy this template when the measurement goal is already clear. Use the matching use-case guide to review event boundaries, success definitions, and the decisions the resulting SQL should support.
Template
Paste this into your coding agent
Replace YOUR_API_KEY, run the flow locally, then verify the generated events and dashboards.
AI agent observability template
Add Telemetry to this AI agent workflow.
Use /skill.md and this Telemetry API key: YOUR_API_KEY
Log:
1. agent_run_started with agent_name, route, user_id, team_id, model, provider, and input_category.
2. agent_tool_called with tool_name, status, latency_ms, retry_count, and error_type.
3. agent_run_completed with status, duration_ms, total_tokens, estimated_cost_usd, output_category, and accepted when available.
4. agent_run_failed with error_type, failed_step, retry_count, and duration_ms.
Create SQL queries for run volume, failure rate by tool, p95 duration, model cost by feature, and accepted-output rate.
Do not log raw prompts, completions, secrets, auth headers, or personal data unless explicitly approved.Events to capture
Verification checklist
Check the events, queries, and dashboard
Events
Synthetic events reach the intended table with stable names and field types.
Queries
The first SQL queries return plausible rows with an explicit time window.
Views
A dashboard uses the real fields and includes enough context to explain a change.
Safety
You checked that events exclude prompts, bodies, credentials, signatures, and private content.
Example event schemas
Event schemas for this workflow
Check what each event records, when to send it, and which field types it needs. Review the example payload and privacy checklist before using it in production.
llm_request_completed
One completed model-provider request.
View schemaagent_tool_call_completed
One completed tool-call attempt within an agent run.
View schemarag_retrieval_evaluated
One evaluator result per eligible query, retrieval version, evaluator, and candidate run.
View schemaUse these queries in Telemetry
Learn about AI agent monitoring
Query agent events to compare tool use, model costs, and outcomes for each run.
Related SQL recipes
More SQL recipes
Run the query using this workflow's event fields and check the example result. Save the result to a dashboard or set up an alert.
Reconstruct a correlated workflow timeline
What happened, in order, during the latest failed workflow?
Open recipeFind AI quality regressions by prompt version
Did the new prompt version improve quality without increasing human handoffs?
Open recipeQuery nested AI tool-call events
Which AI tools and arguments are associated with the most failed calls?
Open recipeDetect repeating AI agent tool loops
Which agent runs appear stuck in a repetitive tool loop?
Open recipeCalculate LLM cost by feature and model
Which product features and models are driving LLM spend?
Open recipeMeasure accepted AI outputs per dollar
Which model and feature combination produces the most accepted outputs per dollar?
Open recipeEvaluate RAG retrieval quality by version
Did the new RAG pipeline improve retrieval and grounded-answer rates?
Open recipeMore templates
AI agent security audit template
Record tool authorization decisions, policy versions, human approvals, and final outcomes. Use selected event fields to keep sensitive payloads out.
Open templateLLM cost tracker
Measure model spend, token usage, latency, failures, and accepted outputs by feature, user, and account.
Open template