Skip to main content
Prometheus and Grafana are widely used to monitor traditional HTTP services. This guide extends that approach to AI inference workloads, showing which operational and model-specific metrics to collect, why they matter, and how they fit into your monitoring stack. AI inference systems share many characteristics with request–response HTTP services, so the four golden signals — traffic, errors, latency, and saturation — remain central. However, modern LLM-driven workflows introduce new observability dimensions (token usage, input/output characteristics, model refusals) that you must track to manage cost, performance, and model quality.
A presentation slide titled "AI Models – Getting to Production" showing two workflow diagrams. The top shows a traditional flow (Data Collection → Model Training → Evaluation) and the bottom shows a modern agentic workflow (Pre-Trained Model → Prompt Tuning & Orchestration → Evaluation).

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.
These signals help you detect cost spikes, latency regressions, and regressions in model behavior (e.g., shorter responses, higher refusal rates).

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).
This makes Prometheus + Grafana a natural observability stack for AI inference: Prometheus collects and stores metrics; Grafana visualizes trends, anomalies, and alerts.
A simple diagram titled "AI Inference Today" showing a Request (image, text, features, etc.) sent to an Inference Server running model(s) which return Predictions (text, label, score, etc.). Arrows indicate the data flow from Request → Inference Server → Prediction.

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.
Key reasons to monitor tokens:
  • 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).
Shifts here may indicate prompt drift, model configuration changes, or differences in underlying model versions.
A presentation slide titled "LLM-Specific Metrics" with two highlighted sections: "Token Usage" and "Output Characteristics." Under Token Usage are items like input/output/total tokens and token usage distributions, while Output Characteristics lists response length distributions and "Empty replies."

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).
Early detection of bad or malformed inputs prevents downstream model quality problems: garbage in → garbage out.

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.
A dashboard-style diagram titled "Service Health and Model Health" with Grafana and Prometheus logos on the left. The main panel shows "AI Inference Observability" and "Basic HTTP Service Observability" with colored tiles for Traffic, Errors, Latency, and Saturation, plus boxes for Token Usage, Response Characteristics, and Input Characteristics.
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).
Example metric naming patterns:
  • 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.

Watch Video