Skip to Content
Self-hostingTGIObservability

TGI observability

Instrument TGI like any production inference backend: server-side Prometheus metrics plus client-side span tags. Without both, you see GPU utilization but not cost per feature.

Prometheus metrics

TGI exposes Prometheus metrics at http://localhost:8080/metrics on the inference host. Scrape it from your Prometheus server or agent running in the same cluster.

Metric areaWhat it tells youAction when bad
Queue depthRequests waiting for batch slotsScale replicas or reduce max-input-length
Time to first token (TTFT)Batch contention or prefill bottleneckDedicated model pools per workload
GPU memoryKV cache pressureEnable quantization or split across GPUs
Request durationEnd-to-end latencyCheck ingress timeouts and client max_tokens

Alert thresholds (starting points)

AlertConditionSeverity
Queue depth highSustained > 10 for 5 minWarning
TTFT P95 spike> 2× baseline for 10 minWarning
GPU OOM restartsAny pod restart with OOMKilledCritical
Error rate5xx > 1% for 5 minCritical

Tune thresholds per model and traffic profile after one week of baseline data.

Span tags

Attribute every client request with labels that slice dashboards by feature:

inference.backend=tgi model_id=meta-llama/Llama-3.1-8B-Instruct feature=support-bot session_id=<uuid> max_tokens=64
TagPurpose
inference.backendFilter TGI vs vLLM vs cloud API in one dashboard
model_idCost attribution per model tier
featureCost per outcome — which product surface burned tokens
session_idDebug multi-turn agent loops
max_tokensVerify guardrails are actually set

Emit spans from your OpenAI SDK middleware, not from TGI itself — TGI metrics cover server health; spans cover business context.

Dashboards

Build three panels minimum:

  1. Throughput — requests/sec, tokens/sec (input + output)
  2. Latency — TTFT P50/P95, total duration P95
  3. Efficiency — GPU utilization vs tokens/sec (identify idle GPUs)

Compare TGI against vLLM on the same dashboard during migration — normalized by model and max_tokens.

Log correlation

Pair Prometheus alerts with structured logs from your API gateway:

{ "request_id": "req_abc123", "model_id": "meta-llama/Llama-3.1-8B-Instruct", "prompt_tokens": 412, "completion_tokens": 58, "latency_ms": 340, "inference.backend": "tgi" }

When queue depth spikes, correlate with feature tags to find the noisy neighbor route.

Quality vs vLLM

If quality drops below vLLM on the same hardware, check quantization and batch settings before blaming the engine. Re-benchmark with matched configs and log model_id + quant flags in spans.

  • Guardrails — alerts that escalate to hard caps
  • API — client instrumentation at the SDK layer
  • Kubernetes — scrape config inside the cluster
Last updated on