How to Monitor LLM Apps in Production: Latency, Cost, and Quality Dashboards
The demo worked. The production app answers slower, costs more than you projected, and occasionally says things that make your users leave. None of these failures page you — they show up as quiet drift in revenue and retention. Monitoring an LLM app means watching three things that traditional API monitoring misses: how long answers take to arrive, how much each answer costs, and whether the answers are any good. This guide walks through the metrics, the dashboards, and the alerts for each.
The Three Pillars: Latency, Cost, Quality
Latency is what users feel. Cost is what finance feels. Quality is what keeps users coming back. Most teams instrument the first, spreadsheet the second, and ignore the third until complaints arrive. You need all three on one screen because they interact: a quality drop often follows a model swap made to cut cost, and a latency spike often precedes a timeout that looks like a quality failure. Instrument them together from day one.
Latency: Measure What Users Feel
Time to first token and tokens per second
For a streaming chat interface, two numbers matter. Time to first token (TTFT) is how long the user stares at a blank box. Tokens per second (or its inverse, time per output token) is how fast the answer fills in. Track both, separately, because they have different causes and different fixes.
import time
def instrumented_call(prompt):
start = time.monotonic()
first_token_at = None
tokens = 0
for chunk in llm.stream(prompt):
if first_token_at is None:
first_token_at = time.monotonic()
tokens += count_tokens(chunk)
total = time.monotonic() - start
metrics.record("ttft_ms", (first_token_at - start) * 1000)
metrics.record("tokens_per_sec", tokens / (total - (first_token_at - start)))
metrics.record("total_latency_ms", total * 1000)
Where the latency actually comes from
Total latency splits into three parts: queue time (waiting for a GPU slot under load), prefill time (processing your prompt), and decode time (generating tokens one by one). Log all three if your provider exposes them. A slow TTFT with fast tokens points at prefill or queueing; a fast first token with a slow trickle points at decode. Without the split you will optimize the wrong half.
Watch the percentiles, not the average. A p50 of 800ms hides a p95 of 9 seconds, and users remember the 9 seconds. Dashboard the p50, p95, and p99 of TTFT per endpoint, and alert on the p95.
Cost: Track Every Token
Token accounting per request
Every request has a token bill: prompt tokens plus completion tokens, each priced differently by your provider. Log both counts on every call, join them against the provider’s current price list, and you get cost per request, per user, per feature, per day. Prices change, so store the price snapshot with each record rather than computing cost at query time.
Frame provider pricing as approximate and check the official pricing page before budgeting — listed prices move and volume tiers complicate the math. What matters for monitoring is the trend: cost per thousand requests, week over week, split by feature.
The costs that sneak up on you
Three patterns quietly multiply token spend. Retries: a flaky tool call retries three times and each retry resends the full conversation. Oversized prompts: a retrieval step stuffs 20 documents into context when the top 5 would do. Verbose completions: no max-tokens cap on a summarizer means essays where a paragraph would do. Track tokens per request over time and investigate any steady climb — it is almost never the model getting more expensive.
Budget alerts that work
Set two alerts. A burn-rate alert fires when hourly spend exceeds a multiple of the recent baseline — it catches runaway loops within the hour. A budget alert fires at 50, 80, and 100 percent of the monthly budget — it catches slow drift. Alert on the multiples, not absolute numbers, so the thresholds survive growth.
Quality: The Hard One
Sampled evals on a golden set
Keep a set of 50 to 200 representative prompts with expected answers or grading rubrics. Re-run them on a schedule — nightly for fast-moving apps, weekly for stable ones — and track the pass rate on a graph. A ten-point drop after a prompt change or model update is the signal that matters. The golden set is also your regression suite: never ship a prompt change without running it.
LLM-as-judge, calibrated
Having a second model grade outputs scales better than human review, but an uncalibrated judge is a random number generator with confidence. Calibrate it: grade a few hundred outputs by hand, compare with the judge’s scores, and measure agreement. If the judge agrees with humans most of the time on your specific task, use it for trend detection, not for absolute scores. Re-calibrate whenever you change the judge model or the task.
Signals from real users
Instrument the feedback your users already give you. Thumbs up and down rates per feature. Regeneration rate — a user hitting “regenerate” is a failed answer. Conversation abandonment right after a tool call. Support tickets that quote the bot. None of these is precise on its own; together they triangulate quality without a labeling budget.
Watch for abuse, not just errors
Production LLM apps attract prompt injection attempts. Log and flag known patterns — instructions to ignore the system prompt, requests to reveal it, encoded payloads — and route them to a review queue rather than blocking blindly, since legitimate users trip naive filters. A rising injection-attempt rate is also an early warning that your app is being probed before a real attack.
Building the Dashboard
A workable stack: emit metrics with OpenTelemetry or a Prometheus client from your application code, store them in Prometheus or your existing metrics backend, and visualize in Grafana. One dashboard, five panels:
- Traffic: requests per minute, split by endpoint and model.
- Latency: p50/p95/p99 TTFT and tokens per second.
- Cost: spend per hour, cost per thousand requests, top spenders by user or feature.
- Quality: eval pass rate over time, user feedback ratio, regeneration rate.
- Errors: error rate by type — provider errors, timeouts, validation failures, content-filter triggers.
Keep the dashboard to one screen. If an executive cannot read it in thirty seconds, split the detail into a second page and keep the overview clean.
Alerting Without the Noise
Alert on symptoms users feel, not on every metric twitch. A starting set that survives contact with production:
- Error rate above 1 percent sustained for 10 minutes.
- p95 TTFT above your SLO for 15 minutes.
- Hourly cost above 2x the 7-day baseline.
- Eval pass rate drops 10 points from baseline.
- Provider error rate spikes (your code is fine; the API is down).
Every alert needs a runbook link and an owner. An alert nobody knows how to act on is just a notification you learn to ignore, and ignored alerts are how the real outage pages you at 3 a.m.
What to Log — and What Not To
Log metadata, not content, by default: request IDs, timestamps, model name, token counts, timings, hashed user identifiers, error codes, and feedback events. Avoid raw prompts and completions in logs — they contain whatever your users typed, including personal data, secrets, and regulated information. If you need content for debugging, sample a small fraction, redact aggressively, set a short retention window, and get the data-handling decision in writing before you ship it.
The Minimum Viable Setup
If you do nothing else this week, ship these five things: a request log with token counts, a cost-per-day graph, TTFT percentiles per endpoint, a weekly eval run on a golden set, and one cost burn-rate alert. That is a day of work and it catches the three failure classes that kill LLM apps quietly — slowness, spend, and drift. Everything else on this page is refinement. Start with the five, then grow the dashboard as the app grows.