LLM observability turns an AI application from a black box into an operating system you can inspect. This guide explains how to monitor quality, cost, latency, refusals, hallucinations, tool failures, feedback, and version changes, with a repeatable estimation method and practical event schema you can adapt to production.
Overview
Monitoring an LLM application requires more than checking whether an API request returned a response. A production system can be available while still producing incomplete answers, using the wrong retrieval context, exceeding a cost target, or taking too long for users. LLM observability combines conventional application monitoring with evaluations designed for probabilistic model behavior.
A useful monitoring plan answers five questions for every request:
- Did it complete? Track request success, timeout, provider error, application error, refusal, and cancellation.
- How long did it take? Measure total latency as well as time spent waiting for the model, retrieval system, tools, and post-processing.
- What did it cost? Record input tokens, output tokens, cached or reused context where available, and the pricing assumptions used by your calculator.
- Was the result useful and safe? Combine automated checks, sampled human review, user feedback, and task-specific evaluation.
- Which configuration produced it? Preserve the model identifier, provider, prompt version, tool definitions, retrieval configuration, and application release.
Observability is not the same as storing every prompt and response indefinitely. Logs may contain personal, confidential, or regulated information. Choose retention, redaction, access controls, and sampling before sending production traces to a monitoring platform.
How to estimate
Start with a request-level cost and reliability model. The exact values will vary by provider and workload, so keep the inputs configurable rather than embedding them in dashboards or code.
Estimated model cost per request = (input tokens ÷ 1,000,000 × input price per million tokens) + (output tokens ÷ 1,000,000 × output price per million tokens).
If a workflow makes several model calls, calculate each call separately and add them together. Include calls made for query rewriting, retrieval decisions, tool selection, summarization, validation, and final response generation. If your provider uses a different billing unit, convert the published unit into a consistent form before comparing scenarios.
Estimated daily cost = requests per day × average cost per request.
For a more useful budget range, calculate at least three scenarios:
- Typical: Use the median or representative token counts and request volume.
- Busy: Use a higher request volume and longer context, such as documents with more retrieved passages.
- Stress: Include retries, tool loops, large inputs, and fallback-model calls.
Do not calculate latency from averages alone. Track the median and upper percentiles for total latency, time to first token, and time to final token. Averages can conceal a small group of requests that are consistently too slow. For streaming applications, define success separately: a request may begin streaming quickly but still fail to produce a complete answer.
Quality needs a denominator. For example, refusal rate should be refusals divided by eligible requests, not refusals divided by all traffic if some requests are health checks or routing calls. Tool error rate should be failed tool calls divided by tool calls attempted. Hallucination or factuality rates should come from a defined evaluation sample or task-specific checker, with the evaluation method recorded alongside the result.
Inputs and assumptions
Use a consistent event schema so that cost, reliability, and quality can be joined later. A practical trace or request record can include:
{
"trace_id": "request-or-workflow-id",
"timestamp": "event-time",
"environment": "production",
"provider": "provider-name",
"model": "model-id",
"application_version": "release-id",
"prompt_version": "template-id-and-version",
"input_tokens": 0,
"output_tokens": 0,
"latency_ms": 0,
"time_to_first_token_ms": 0,
"status": "success",
"refusal": false,
"tool_calls": 0,
"tool_errors": 0,
"retrieval_count": 0,
"user_feedback": "unrated",
"evaluation_result": "not-sampled"
}Keep workflow-level and span-level data separate. One user request may contain retrieval, model, tool, and validation spans. The workflow record should summarize the outcome; child spans should explain where time, tokens, and failures occurred.
Define assumptions before building a dashboard:
- What counts as a request: a user turn, an end-to-end workflow, or an individual model call?
- Which token categories are billable for the selected provider and model?
- Are retries included in cost and latency?
- How are streaming interruptions classified?
- What sample size is required before displaying a quality rate?
- Which fields are redacted, hashed, or excluded from logs?
For quality, create a small evaluation set that reflects real tasks. Label expected properties such as citation support, valid JSON, correct tool selection, policy compliance, or answer completeness. Automated graders can help with triage, but sampled human review remains useful for detecting failure modes that a simple score misses. Store the rubric version with each evaluation result.
Worked examples
Suppose one workflow performs retrieval, a planning call, and a final answer call. Rather than treating it as one opaque request, record the token and latency contribution of each span. If the final response becomes slow, the trace can show whether the cause was a large retrieved context, a tool retry, or the final model call.
For a monthly estimate, create a worksheet with these columns: workflow name, calls per workflow, expected workflows per day, average input tokens, average output tokens, retry rate, fallback rate, and the current provider prices. The formula for each call is the token formula above. Multiply by calls per workflow, then by expected workflows per day. Add an explicit allowance for retries and fallbacks rather than hiding them inside an optimistic average.
Example structure:
| Component | Input to record | Why it matters |
|---|---|---|
| Retrieval call | Documents, chunks, retrieval latency | Shows context and search overhead |
| Model call | Model, prompt version, tokens, latency | Supports cost and regression analysis |
| Tool span | Tool name, duration, status, retry count | Separates external failures from model failures |
| Outcome | Refusal, feedback, evaluation result | Connects technical data to usefulness |
A dashboard should include an overview row for request volume, success rate, total token usage, estimated cost, median latency, upper-percentile latency, refusal rate, tool error rate, and user feedback. Add filters for model, prompt version, application release, tenant, workflow, and time range. A second dashboard should focus on quality: evaluation score by task, citation or schema validity, sampled failures, and changes after a prompt or model release.
When an alert fires, inspect a trace sample rather than immediately changing the prompt. Compare affected requests with a known-good period, then check whether traffic mix, context length, provider behavior, tool availability, or a deployment changed.
When to recalculate
Recalculate LLM production metrics whenever an input to the operating model changes. The most obvious trigger is a provider pricing change, but it is not the only one. Revisit the estimate after changing the model, prompt, context window, retrieval top-k value, output limit, tool workflow, retry policy, traffic forecast, or fallback strategy.
Review observability after every significant model update or API migration. Confirm that model identifiers, token fields, finish reasons, refusal classifications, streaming events, and error codes still map correctly into your schema. A provider change may preserve application behavior while changing the fields needed for cost or failure analysis. The LLM API migration guide can be used alongside this checklist when moving between providers.
During incidents, compare the current release with the last known-good prompt and model versions. Prompt regression tests are useful before deployment, while production traces reveal failures that only appear with real documents, users, and tools. For a broader evaluation plan, see the guide to benchmarking LLMs for a real-world use case.
Make recalculation routine: review high-volume dashboards weekly, inspect sampled quality results on a defined schedule, and perform a full cost and reliability review whenever traffic or model configuration changes materially. Keep the spreadsheet or configuration file with its date, pricing assumptions, metric definitions, and sample period. That record makes future comparisons reproducible and helps the team distinguish a real model regression from a change in workload.
Practical next step: instrument one complete workflow first, including model, retrieval, tool, and outcome spans. Establish a baseline for cost, latency, failures, and quality before adding alerts. Then expand coverage to the workflows that carry the greatest user or financial risk.