
Why LLM inference changes the monitoring story
Modern LLM-based systems often rely on pre-trained models (hosted yourself or via API). The focus before deployment shifts from heavy model training to prompt design, orchestration, and runtime behavior. That means operational monitoring must capture both classic service health and model-specific signals:- Classic operational metrics: request rate, error rate, p95/p99 latency, CPU/memory saturation.
- Model-specific metrics: token usage, response length distributions, safety/refusal events, truncated outputs.
Typical inference architecture
From an architectural viewpoint, an inference service typically behaves like an HTTP service:- Clients send requests (text, images, features).
- The inference server calls one or more models.
- The server returns predictions (text, labels, scores).

Token usage: a first-class signal
Token usage is critical for LLMs. Each request includes input tokens and output tokens; both affect cost and latency. Track distributions (not just averages) so you can detect shifts like a sudden jump from ~500 to ~5,000 tokens per request.Track token counts (input, output, and total) and token-size distributions over time. These metrics let you spot sudden changes in usage patterns that affect cost and latency.
- Cost control (especially with third-party APIs that bill per token).
- Capacity planning (longer responses increase CPU/GPU time and latency).
- Regression detection (unexpected increases in prompt size or verbosity).
Output characteristics and model behavior
Monitoring whether the model responded is insufficient. Capture how it responded:- Response length distributions (mean, median, tail percentiles).
- Rate of empty or truncated outputs.
- Safety filters or refusal hits.
- Changes in answer format (e.g., HTML returned instead of JSON).

Input characteristics: detect bad inputs early
Instrument the incoming prompts and features:- Distribution of prompt lengths and feature cardinality.
- Rate of malformed or invalid requests.
- Changes in context structure (e.g., more system messages, longer chat histories).
Service health + model health: combined observability
Combine traditional service metrics with model metrics so dashboards show operational and model health side-by-side. This approach helps you correlate cost or quality regressions with specific service incidents or model changes.
Recommended metrics to collect
Use Prometheus gauges, counters, and histograms as appropriate. Below is a set of suggested metrics to expose and visualize in Grafana.
Note: wrap any literal examples that include braces in backticks to ensure MDX renders them correctly (as shown above).
Implementation notes and Prometheus examples
- Expose tokens as counters (increment per request) and also maintain histograms for token-size distribution.
- Use labels to differentiate models, deployment environments, or inference modes (e.g.,
model="gpt-4",env="prod"). - Alert on both absolute thresholds (e.g., cost-per-hour) and sudden relative changes (e.g., 5x increase in input tokens in 15 minutes).
ai_tokens_total{direction="input",model="gpt-4"}ai_response_length_bytes{model="bert-classifier"}ai_response_refused_total{reason="safety_filter"}
Alerts and dashboards
- Build Grafana panels that pair service KPIs (throughput, errors, latency) with model KPIs (token rate, refusal rate, truncation).
- Create alerts for:
- Token rate spikes (cost alert).
- Latency p95/p99 regressions (performance alert).
- Rising refusal/truncation rates (model quality alert).
- Surge in malformed requests (integration/client issue).
Monitor token usage closely when using paid third-party LLM APIs — a small change in average token counts can dramatically increase costs. Set budget or rate-based alerts tied to token consumption.
Summary
- Treat AI inference like an HTTP service operationally, but add model-specific metrics.
- Continue to instrument the four golden signals (traffic, errors, latency, saturation).
- Augment with token usage, input characteristics, and output characteristics to monitor cost, performance, and model quality.
- Visualize these signals in Grafana and collect them with Prometheus to run and troubleshoot AI inference reliably.
Links and references
- Prometheus — monitoring and alerting toolkit.
- Grafana — observability and visualization platform.
- The Four Golden Signals — SRE Book