Prompt
I need LLM monitoring with alerting for latency, timeout, and token spend spikes
Latest observation
Oct 19, 2026
OpenAI APIWeb search: off
Here’s a practical way to set up LLM monitoring with alerting for latency, timeouts, and token spend spikes.
What to monitor
At minimum, track these per request and in aggregates:
Request-level metrics
- Latency
- total request duration
- time to first token
- streaming duration
- Timeouts / failures
- request timed out
- upstream API errors
- retries triggered
- Token usage
- input tokens
- output tokens
- total tokens
- Cost
- estimated cost per request
- cost by model / endpoint / tenant / user
- Quality / behavior
- response length
- finish reason
- error rate
Aggregate metrics
- p50 / p95 / p99 latency
- timeout rate
- error rate
- tokens per request
- spend per minute/hour/day
- spend by model, customer, environment, or feature
Recommended alert rules
Use a mix of threshold and anomaly/spike alerts.
Latency alerts
- P95 latency > X ms for 5–10 min
- P99 latency > Y ms for 5 min
- Median latency increases by > N% vs baseline
Example:
- Alert if
p95 latency > 3s for 10m - Alert if
p99 latency > 8s for 5m
Timeout alerts
- Timeout rate > 1–2% over 5 min
- Absolute timeout count > N
- Timeouts increasing rapidly vs previous hour/day
Example:
- Alert if
timeouts / requests > 0.02 for 5m - Alert if
timeouts > 50 in 10m
Token spend alerts
- Tokens/minute spikes above baseline
- Daily spend exceeds budget threshold
- Cost per request jumps unusually
- Unexpected model switch causing higher spend
Example:
- Alert if
total token spend > 2x rolling 1h average - Alert if
daily cost > 80% of budget - Alert if
tokens per request p95 > baseline + 50%
Best-practice alert design
To avoid noisy alerts:
- Use rolling windows
- 5m, 15m, 1h windows
- Require sustained breaches
- e.g. alert only if condition holds for 3/5 datapoints
- Separate severity
- Warning: early degradation
- Critical: customer impact or budget breach
- Group by dimension
- model, route, tenant, region, deployment version
- Add suppression / deduplication
- prevent alert storms
- Include context in the alert
- last values, baseline, top offending model/route, recent deploys
What to log for each LLM request
Capture structured logs like:
{
"timestamp": "2026-10-19T12:34:56Z",
"request_id": "abc123",
"trace_id": "trace-789",
"model": "gpt-4.1-mini",
"route": "/chat",
"tenant_id": "tenant_42",
"latency_ms": 2140,
"time_to_first_token_ms": 480,
"input_tokens": 820,
"output_tokens": 220,
"total_tokens": 1040,
"estimated_cost_usd": 0.0132,
"timeout": false,
"error": null
}
This makes it easy to build dashboards and alerts.
Suggested dashboard layout
Overview
- Request volume
- p95 latency
- timeout rate
- spend per hour/day
- errors
Drilldowns
- by model
- by endpoint/feature
- by tenant/customer
- by environment
- by deployment version
SLO panels
- latency SLO compliance
- timeout SLO compliance
- budget burn rate
Example alerting logic
If you use Prometheus/Grafana, Datadog, New Relic, or CloudWatch, the same logic applies.
Latency
p95(latency_ms) > 3000 for 10m
Timeout rate
rate(timeouts[5m]) / rate(requests[5m]) > 0.02
Spend spike
sum(token_cost_usd[15m]) > 2 * avg(sum(token_cost_usd[15m]) over last 24h)
Tooling options
Open-source
- Prometheus + Grafana + Alertmanager
- OpenTelemetry for traces/metrics/logs
- Loki/ELK for logs
Managed
- Datadog
- New Relic
- Grafana Cloud
- Arize Phoenix / LangSmith for LLM observability
- Honeycomb for traces
Practical implementation approach
- Instrument LLM calls with metrics + structured logs
- Export metrics to your monitoring stack
- Build dashboards for latency, timeout rate, and cost
- Add threshold alerts first
- Add anomaly/spike alerts after you have a baseline
- Route alerts to Slack/PagerDuty/email
- Include links to traces/logs in each alert
If you want, I can also give you:
- a Prometheus/Grafana alert rule set,
- a Datadog monitor setup, or
- a Python/OpenTelemetry instrumentation example for your LLM calls.